geView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
- (IBAction)btnClick:(UIButton *)sender;
@end
@implementation CZAppView
- (void)setApp:(CZApp *)app
{
self.iconImage.image = [UIImage imageNamed:app.icon];
self.nameLabel.text = app.name;
}
- (IBAction)btnClick:(UIButton *)sender
{
//1.让按钮禁用
sender.enabled = NO;
//2.让屏幕中间显示一个文字
UILabel *label = [[UILabel alloc]init];
//设置属性
label.bounds = CGRectMake(0, 0, 100, 30);
label.center = self.superview.center;
//设置背景颜色
label.backgroundColor = [UIColor blackColor];
//设置文字
label.text = @"正在下载...";
label.textColor = [UIColor whiteColor];
label.font = [UIFont systemFontOfSize:13];
label.textAlignment = NSTextAlignmentCenter;
label.alpha = 0;
//添加到对应控件中
[self.superview addSubview:label];
//添加动画效果
[UIView animateWithDuration:2 animations:^{
label.alpha = 1;
} completion:^(BOOL finished) {
if(finished)
{
// [UIView animateWithDuration:2 animations:^{
// label.alpha = 0;
// } completion:^(BOOL finished) {
// if(finished)
// {
// [label removeFromSuperview];
// }
// }];
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionCurveLinear animations:^{
label.alpha = 0;
} completion:^(BOOL finished) {
[label removeFromSuperview];
}];
}
}];
}
@end