解析iOS应用的UI开发中懒加载和xib的简单使用方法

2020-01-14 18:19:35王振洲

        [ appview.appbtn addTarget:self action:@selector(appviewbtnClick:) forControlEvents:UIControlEventTouchUpInside];
       
    }
}

/**按钮的点击事件*/
-(void)appviewbtnClick:(UIButton *)btn
{
    YYapp *apps=self.app[btn.tag];
    UILabel *showlab=[[UILabel alloc]initWithFrame:CGRectMake(60, 450, 200, 20)];
    [showlab setText:[NSString stringWithFormat: @"%@下载成功",apps.name]];
    [showlab setBackgroundColor:[UIColor lightGrayColor]];
    [self.view addSubview:showlab];
    showlab.alpha=1.0;
    
    //简单的动画效果
    [UIView animateWithDuration:2.0 animations:^{
        showlab.alpha=0;
    } completion:^(BOOL finished) {
        [showlab removeFromSuperview];
    }];
}

@end


YYappview.h文件代码(已经连线)
复制代码
#import <UIKit/UIKit.h>

 

@interface YYappview : UIView
@property (strong, nonatomic) IBOutlet UIImageView *appimg;
@property (strong, nonatomic) IBOutlet UILabel *applab;
@property (strong, nonatomic) IBOutlet UIButton *appbtn;
@end



注:相关教程知识阅读请移步到IOS开发频道。