#import "ViewController.h"

 

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    [self shuibowen];

}

- (void)shuibowen{

    self.view.backgroundColor = [UIColor blackColor];

    //实例按钮

    UIButton * xiuButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];

    //设置按钮位置 居中

    xiuButton.center =self.view.center;

    [xiuButton setBackgroundImage:[UIImage imageNamed:@"alipay_msp_op_success"] forState:UIControlStateNormal];

    [self.view addSubview:xiuButton];

    //设置监听

    [xiuButton addTarget:self action:@selector(sizebowen:) forControlEvents:UIControlEventTouchUpInside];

    

}

//点击按钮 水波纹效果

- (void)sizebowen:(UIButton *)sender{

    for (int i = 0; i<10; i++) {

        

        //设置一个在button后面的图片

        UIView * bview = [[UIView alloc]initWithFrame:sender.frame];

        //设置颜色

        [bview setBackgroundColor:[UIColor colorWithRed:78/255.0 green:190/255.0 blue:245/255.0 alpha:1]];

        //设置图片的圆角效果

        bview.layer.cornerRadius = sender.frame.size.width/2;

        //设置层级

        [self.view insertSubview:bview atIndex:0];

        //设置连续放大效果(水波纹)效果

        //参数1:动画时间

        //参数2:延迟执行动画的时间

        //参数3:动画效果,传递0,表示默认

        //参数4:执行的动画代码块

        //参数5:动画执行完成后的block代码块

        [UIView animateWithDuration:3

                              delay:0.3 * i

                            options:0

                         animations:^{

                             bview.transform =CGAffineTransformMakeScale(5, 5);

                             //alpha表示透明度 取值1-0 1为实  0为全透明

                             //@property(nonatomic)                 CGFloat           alpha; animatable. default is 1.0

                             bview.alpha = 0;

                         } completion:^(BOOL finished) {

                             [bview removeFromSuperview];

                         }];

        

    }

}

- (void)didReceiveMemoryWarning {

    //移除动画结束后bview 的透明度为0,也没有存在的意义 可以释放掉l

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

 

@end