簡體   English   中英

iOS Swift:UIScrollView的自定義滾動動畫

[英]iOS Swift: Custom scroll animation for UIScrollView

使用UIScrollView的scrollToItemAtIndexPath方法時,可以使用自定義動畫嗎? 我想使用彈簧動畫或自定義動畫曲線。

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上訪問該特定項目的框架,然后滾動到所需動畫塊中的該矩形。 那應該工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM