drawLayer被正确调用并在我开始动画之前正确绘制.但我不能让图层在边界动画的每一步调用它的drawLayer方法.相反,它只是将其称为ONCE,立即跳转到动画最后一帧的“结束边界”.
// self.bg is a property pointing to my custom UIVIEwself.bg.layer.needsdisplayOnBoundsChange = YES;self.bg.layer.mask.needsdisplayOnBoundsChange = YES;[UIVIEw animateWithDuration:2 delay:0 options:UIVIEwAnimationoptionCurveEaSEOut|UIVIEwAnimationoptionautoreverse|UIVIEwAnimationoptionRepeat animations:^{ [CATransaction begin]; self.bg.layer.bounds = bounds; self.bg.layer.mask.bounds = bounds; [CATransaction commit]; self.bg.bounds = bounds;} completion:nil];
为什么边界不报告其动画(不仅仅是最终帧)的变化?我究竟做错了什么?
解决方法 这可能有助于……很多人都不知道Core Animation有一个supercool功能,允许您以可以设置动画的方式定义自己的图层属性.我使用的一个例子是给CALayer子类赋予厚度属性.当我使用Core Animation制作动画时……
CABasicAnimation* ba = [CABasicAnimation animationWithKeyPath:@"thickness"];ba.tovalue = @10.0f;ba.autoreverses = YES;[lay addAnimation:ba forKey:nil];
…效果是drawInContext:或drawLayer:…在整个动画中被重复调用,允许我根据每个时刻的当前厚度属性值重复更改图层的绘制方式(中间值为动画过程).
在我看来,这可能是你所追求的那种东西.如果是这样,您可以在此处找到可下载的示例:
https://github.com/mattneub/Programming-iOS-Book-Examples/tree/master/ch17p498customAnimatableProperty
讨论(来自我的书)这里:
http://www.apeth.com/iOSBook/ch17.html#_making_a_property_animatable
总结以上是内存溢出为你收集整理的ios – 无法让CALayer更新其drawLayer:在边界动画期间全部内容,希望文章能够帮你解决ios – 无法让CALayer更新其drawLayer:在边界动画期间所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)