案例(咻一咻)
-(void)setupUI {
//设置背景颜色
self.view.backgroundColor = [UIColor colorWithRed:26/255.0 green:28/255.0 blue:49/255.0 alpha:1];
//创建button
UIButton *btn = [[UIButton alloc] init];
//设置btn属性
[btn setImage:[UIImage imageNamed:@"alipay_msp_op_success"] forState:UIControlStateNormal];
[btn sizeToFit];
btn.center = self.view.center;
//添加到父容器
[self.view addSubview:btn];
//添加点击事件
[btn addTarget:self action:@selector(show:) forControlEvents:UIControlEventTouchUpInside];
//添加圆
UIView *circleView = [self createCircle];
[self.view insertSubview:circleView atIndex:0];
}
-(void)show:(UIButton *)button {
//禁用交互
button.enabled = NO;
for (int i = 0; i < 20; i++) {
//创建圆
UIView *v = [self createCircle];
//添加到父容器
[self.view insertSubview:v atIndex:0];
//动画效果
[UIView animateWithDuration:2 delay:0.5 * i options:0 animations:^{
v.transform = CGAffineTransformMakeScale(5,5);
v.alpha = 0;
v.backgroundColor = self.view.backgroundColor;
} completion:^(BOOL finished) {
[v removeFromSuperview];
}];
}
}
//创建view
-(UIView *)createCircle {
//创建view
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
//设置属性
v.backgroundColor = [UIColor colorWithRed:47/255.0 green:167/255.0 blue:244/255.0 alpha:1];
v.center = self.view.center;
v.layer.cornerRadius = 50;
//返回view
return v;
}
网友评论