1
當用戶在水平滾動時滾動標籤以移動到另一個位置時,我很不習慣。使用UIScrollView進行滾動時的動畫SWIFT
以下是摘錄我有:
override func viewDidLoad() {
super.viewDidLoad()
buttonTextSpacing(UIButton: vysionButton, lineSpacing: 2.5, UIColor: .black)
buttonTextSpacing(UIButton: converseButton, lineSpacing: 2.5, UIColor: .black)
buttonTextSpacing(UIButton: storiesButton, lineSpacing: 2.5, UIColor: .black)
self.storiesCollectionView.delegate = self
self.storiesCollectionView.dataSource = self
// Scroll View
self.scrollView.contentSize = CGSize(width: self.scrollView.frame.width*2, height: self.scrollView.frame.height)
self.scrollView.addSubview(storiesCollectionView)
self.scrollView.showsHorizontalScrollIndicator = false
self.scrollView.delegate = self
}
func scrollViewDidScroll(scrollUIView: UIScrollView) {
print("scrollViewDidScroll")
DispatchQueue.main.async {
UIView.animate(withDuration: 0.4, delay: 0, options: UIViewAnimationOptions.curveEaseOut, animations: {
self.scrollLabel.center.x = self.storiesButton.center.x - 1
}, completion: nil)
}
}
基本上什麼即時試圖實現的是,當用戶滾動,動畫開始,但沒有完成,直到滾動完成下一個自定義的UIView(我也啓用分頁)。
目前它不這樣做,我不能夠在滾動時調用滾動事件,甚至不使標籤變爲動畫(到新位置)。
非常感謝您的任何建議或幫助。
乾杯, PON