我想在简单的UI中的过渡之间创建柔和的动画:
查看移动
当调用scrollToPoint:时,用于移动视图以指向该过渡没有动画。我是可可编程的新手(iOS是我的背景)。而且我不知道如何正确使用.animator或NSAnimationContext。
另外,我阅读了《核心动画指南》,但没有找到解决方案。
请帮忙 !!!
scrollToPoint不可设置动画。只有动画属性(例如NSAnimatablePropertyContainer中的边界和位置)会被动画化。您不需要对CALayer进行任何操作:删除wantLayer和CALayer的内容。然后使用以下代码对其进行动画处理。
- (void)scrollToXPosition:(float)xCoord {
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:5.0];
NSClipView* clipView = [_scrollView contentView];
NSPoint newOrigin = [clipView bounds].origin;
newOrigin.x = xCoord;
[[clipView animator] setBoundsOrigin:newOrigin];
[_scrollView reflectScrolledClipView: [_scrollView contentView]]; // may not bee necessary
[NSAnimationContext endGrouping];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句