示例圖如下
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:35 / 255.0 green:39 / 255.0 blue:63 / 255.0 alpha:1];
//設(shè)置中間點(diǎn)擊按鈕
UIButton *btn = [[UIButton alloc] init];
[btn setImage:[UIImage imageNamed:@"zhifubao"] forState:UIControlStateNormal];
[btn sizeToFit];
btn.center = self.view.center;
[self.view addSubview:btn];
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)btnClick:(UIButton *)btn {
for (NSInteger i = 0; i < 10; i++) {
// 1.創(chuàng)建一個(gè)圓圈view
UIView *circleView = [[UIView alloc] init];
circleView.backgroundColor = [UIColor colorWithRed:0 green:170 / 255.0 blue:238 / 255.0 alpha:1];
circleView.frame = btn.frame;
// [self.view addSubview:circleView];
// 把圓圈添加到控制器的view上并且加上支付寶按鈕的上面
// [self.view insertSubview:circleView aboveSubview:btn];
// 在支付寶按鈕按鈕下面插入一個(gè)view
[self.view insertSubview:circleView belowSubview:btn];
circleView.layer.cornerRadius = circleView.frame.size.width * 0.5;
circleView.layer.masksToBounds = YES;
// 讓每一個(gè)圓圈延遲時(shí)間不一樣
[UIView animateWithDuration:1.0 delay:i * 0.2 options:0 animations:^{
circleView.transform = CGAffineTransformMakeScale(16, 16);
circleView.alpha = 0;
} completion:^(BOOL finished) {
[circleView removeFromSuperview];
}];
}
}
代碼沒什么難度,思路很重要。