ios点击产生波纹效果

ios点击产生波纹效果

by 伍雪颖

- (void)viewDidLoad
{
    [super viewDidLoad];
    RippleView = [[UIView alloc] initWithFrame:(CGRect){0,0,300,300}];
    RippleView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
    RippleView.layer.cornerRadius = 150;
    RippleView.layer.masksToBounds=true;
    RippleView.alpha=0;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];
    [self.view addSubview:RippleView];
    RippleView.center = location;
    RippleView.transform = CGAffineTransformMakeScale(0.5, 0.5);
    [UIView animateWithDuration:0.1
                     animations:^{
                         RippleView.alpha=1;
                         self.view.alpha=0.3;
                     }];
    [UIView animateWithDuration:0.7
                          delay:0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         RippleView.transform = CGAffineTransformMakeScale(1,1);
                         RippleView.alpha=0;
                         self.view.alpha=1;
                     } completion:^(BOOL finished) {
                         [RippleView removeFromSuperview];
                     }];
}


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。