首页 > 代码库 > ios点击产生波纹效果
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]; }]; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。