标签:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
UIView * _circleView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setupUI];
}
//开始咻一咻
-(void)startXiuYiXiu:(UIButton *)button{
_circleView.backgroundColor = [UIColor colorWithRed:61/255.0 green:107/255.0 blue:147/255.0 alpha:1.0];
//禁用按钮
button.enabled = NO;
CGFloat delay = 1.0;
CGFloat scale = 3;
NSInteger count = 20;
//循环添加多个视图动画
for (NSInteger i = 0; i<count; i++) {
UIView *animationView = [self circleView];
animationView.backgroundColor = _circleView.backgroundColor;
[self.view insertSubview:animationView atIndex:0];
[UIView animateWithDuration:2
delay:i * delay
options:UIViewAnimationOptionCurveLinear
animations:^{
animationView.transform = CGAffineTransformMakeScale(scale, scale);
animationView.backgroundColor = self.view.backgroundColor;
animationView.alpha = 0.0;
} completion:^(BOOL finished) {
[animationView removeFromSuperview];
if (i == count - 1) {
button.enabled = YES;
}
}];
}
}
///准备界面
-(void)setupUI {
self.view.backgroundColor = [UIColor colorWithRed:35/255.0 green:39/255.0 blue:63/255.0 alpha:1.0];
UIButton *button = [[UIButton alloc]init];
[button setImage: [UIImage imageNamed:@"alipay_msp_op_success"]forState:UIControlStateNormal];
[button sizeToFit];
button.center=self.view.center;
[self.view addSubview:button];
_circleView = [self circleView];
[self.view insertSubview:_circleView belowSubview:button];
[button addTarget:self action:@selector(startXiuYiXiu:) forControlEvents:UIControlEventTouchUpInside];
}
-(UIView *)circleView {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.center = self.view.center;
view.backgroundColor = [UIColor colorWithRed:52/255.0 green:143/255.0 blue:242/255.0 alpha:1.0];
view.layer.cornerRadius = 50.0;
return view;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
标签:
原文地址:http://www.cnblogs.com/zxc66965427/p/5380738.html