dynamicMask.gif
-(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"];
}
网友评论