-(void)initSubViews{
CGFloat maskW = 150;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.maskView.bounds];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.view.center.x, self.view.center.y) radius:maskW startAngle:0.0 endAngle:2*M_PI clockwise:NO];
[path appendPath:circlePath];
_shaperLayer = [CAShapeLayer layer];
_shaperLayer.path = path.CGPath;
self.maskView.layer.mask = _shaperLayer;
}
- (IBAction)progressSlider:(UISlider *)sender {
CGFloat maskW = sender.value*self.view.bounds.size.height;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.maskView.bounds];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.view.center.x, self.view.center.y) radius:maskW startAngle:0.0 endAngle:2*M_PI clockwise:NO];
[path appendPath:circlePath];
_shaperLayer.path = path.CGPath;
self.maskView.layer.mask = _shaperLayer;
}
- (IBAction)begainAction {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [NSValue valueWithCGPoint:self.img_book.center];
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(70, 90)];
animation.duration = 2.0;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.img_book.layer addAnimation:animation forKey:@"positionAnimation"];
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.values = @[@1,@1.2,@1];
scaleAnimation.duration = 2.0;
scaleAnimation.fillMode = kCAFillModeForwards;
scaleAnimation.removedOnCompletion = NO;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.img_book.layer addAnimation:scaleAnimation forKey:@"scaleAnimation"];
}
动态遮罩实现
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 动态在dom节点上添加透明遮罩层1.获取dom节点距离浏览器上边和左边的距离,即offsetTop和offsetL...
- Modal可以使你应用中RN编写的那部分内容覆盖在原生视图上显示。实现遮罩的功能 实现modal代码: 测试发现o...
- 首先,我们来分解一下iPhone锁屏文字动画效果是怎样实现的: 1.首先我们要做一个CAGradientLayer...