码迷,mamicode.com
首页 > 移动开发 > 详细

ios点击产生波纹效果

时间:2014-08-06 14:50:11      阅读:482      评论:0      收藏:0      [点我收藏+]

标签:ios   animatewithduration   

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];
                     }];
}


ios点击产生波纹效果,布布扣,bubuko.com

ios点击产生波纹效果

标签:ios   animatewithduration   

原文地址:http://blog.csdn.net/rainlesvio/article/details/38400317

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!