【发布时间】:2012-10-09 05:17:36
【问题描述】:
我有一个 UIImageView 和上面一样的图像,所以我要做的是逐渐减少和增加图像的形状。
显然,为了完成上述任务,我必须应用蒙版,所以我创建了一个圆形 CAShapeLayer 并添加到 UIImageView 层,如果我改变我的半径,它会正常工作,它只会显示那个数量的图像 wrt 半径。
我的问题是我们如何应用动画以便它以动画形式显示。请指导我,我无法用关键帧动画实现。
以下是屏蔽 wrt 半径的代码。
// Set up the shape of the circle
int rChange = 0; // Its doing proper masking while changing this value
int radius = 123.5-rChange;
CAShapeLayer *circle = [CAShapeLayer layer];
// Make a circular shape
circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0+rChange, 0+rChange, 2.0*radius, 2.0*radius)
cornerRadius:radius].CGPath;
// Configure the apperence of the circle
[circle setFillColor:[[UIColor blackColor] CGColor]];
[[self.originalImageView layer] setMask:circle];
self.originalImageView.layer.masksToBounds = YES;
其中 123.5 是图像的最大半径 而 originalImageView 是 myUIImageView
【问题讨论】:
标签: iphone mask cabasicanimation cakeyframeanimation cashapelayer