软滚动动画NSScrollView scrollToPoint:

胜利者

我想在简单的UI中的过渡之间创建柔和的动画:

第一张幻灯片第二张幻灯片第三张幻灯片

查看移动

看法

当调用scrollToPoint:时,用于移动视图以指向该过渡没有动画。我是可可编程的新手(iOS是我的背景)。而且我不知道如何正确使用.animator或NSAnimationContext。

另外,我阅读了《核心动画指南》,但没有找到解决方案。

可以在Git Hub仓库上找到源

请帮忙 !!!

昂贵的叔丁

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章