【问题标题】:iOS Swift: Custom scroll animation for UIScrollViewiOS Swift:UIScrollView 的自定义滚动动画
【发布时间】:2015-03-27 08:59:12
【问题描述】:

在 UIScrollView 使用 scrollToItemAtIndexPath 方法时,是否可以使用自定义动画?我想使用弹簧动画或自定义动画曲线。

【问题讨论】:

    标签: ios swift uikit


    【解决方案1】:
    if let itemFrame: CGRect = collectionView.layoutAttributesForItemAtIndexPath(indexPath).frame {
        //UIView animate block here
        {
            collectionView.scrollToItemIndexPath(indexPath, yourScrollPosition, false/*animated parameter*/)
            /*or
            collectionView.setContentOffset(corresponding content offset to itemFrame)*/
        }
    }
    

    首先在 indexPath 访问该特定项目的帧,然后滚动到所需动画块内的该矩形。应该可以的。

    【讨论】:

    • 那种作品,虽然我正在制作动画的视图立即消失了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多