[英]How do I segue through dates?
想象一下,屏幕上的每個視圖都顯示了有關特定日期的一些信息。 向右滑動將日期提前一天,向左滑動顯示昨天的數據。
我設法通過捕獲滑動手勢並更新屏幕上的數據來實現這一點,但我沒有獲得滑動動畫。 我猜這樣做的正確方法是將視圖控制器與其自身進行連接並進行更新,但我不確定。 任何人都可以建議正確的方法來做到這一點嗎?
每個方向都需要一個這樣的塊。 這是用於向右滑動(返回)。 另一個方向是相反的。
UIView.animateWithDuration(NSTimeInterval(0.1), animations: {
//swipes view off screen
self.calView.frame.origin.x = self.view.frame.width
})
UIView.animateWithDuration(NSTimeInterval(0), delay: NSTimeInterval(0.1), options: UIViewAnimationOptions(rawValue: 0), animations: {
//jumps to other side
self.calView.frame.origin.x = -self.view.frame.width
}, completion: { _ in
//reload data, subtract one, whatever
self.setCurrentDate()
self.collectionView?.reloadData()
})
UIView.animateWithDuration(NSTimeInterval(0.1), delay: NSTimeInterval(0.2), options: UIViewAnimationOptions(rawValue: 0), animations: {
//swipes back to center
self.calView.frame.origin.x = 0
}, completion: nil)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.