Przeglądaj źródła

缩短动画时间

jsonwang 4 lat temu
rodzic
commit
7eba7797ea

+ 6 - 3
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Home/Views/Banner/MVBanner.swift

@@ -194,9 +194,12 @@ public extension MVBanner {
     }
     final func scrollToItem(at index: Int, animated: Bool) {
         let indexPath = IndexPath(item: index, section: 0)
-        self.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: animated)
-        let page = self.realIndex(index: index)
-        self.setCurrentPage(page)
+        UIView.animate(withDuration: 0.05, animations: { [weak self] in
+            self?.collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: animated)
+            let page = self?.realIndex(index: index) ?? 0
+            self?.setCurrentPage(page)
+        })
+      
     }
 }