我想創建一個非常簡單的佈局,類似條紋的iOS應用程序有哪些,你可以在這裏看到:https://stripe.com/img/dashboard_iphone/screencast.mp4滾動的UITableView向上滑動至屏幕的頂部斯威夫特
在圍繞0:06S表視圖刷卡它會移動到窗口的頂部。
是否有任何雨燕簡單的指令,顯示這種設計模式我看到它無處不在,但不知道如何創建它
我想創建一個非常簡單的佈局,類似條紋的iOS應用程序有哪些,你可以在這裏看到:https://stripe.com/img/dashboard_iphone/screencast.mp4滾動的UITableView向上滑動至屏幕的頂部斯威夫特
在圍繞0:06S表視圖刷卡它會移動到窗口的頂部。
是否有任何雨燕簡單的指令,顯示這種設計模式我看到它無處不在,但不知道如何創建它
在您自定義的UIView,你需要幾個變量和幾個覆蓋。確保用戶交互在你的故事板的UIView的啓用,然後在您的自定義類加載:
var startPosition: CGPoint?
var originalHeight: CGFloat?
之後,添加以下內容:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch = touches.first
startPosition = touch?.locationInView(self)
originalHeight = self.frame.height
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch = touches.first
let endPosition = touch?.locationInView(self)
let difference = endPosition!.y - startPosition!.y
let newFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y + difference, self.frame.width, self.frame.height - difference)
self.frame = newFrame
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
在UIScrollView.h:
// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.
// On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.
var scrollsToTop: Bool // default is YES.
初始化滾動視圖的委託(除非你已經有了,可能在你的viewDidLoad中),然後將其設置爲true。
像這樣:
myScrollView.scrollsToTop = true
如果你想確保你的滾動視圖委託允許這一點,從UIScrollViewDelegate的協議檢查這個方法:
optional func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool // return a yes if you want to scroll to the top. if not defined, assumes YES
請評論的任何問題。
那是偉大的,但它的少做點擊狀態欄將其向上滾動,以及如何疊加兩個視圖(具有圖形和下方的視圖),然後滾動時允許表視圖向上移動並重疊圖形視圖 –
當滾動到達頂端?如果你檢查UIScrollView.h,那麼我提到的最後一個叫做scrollViewDidScrollToTop的另一種方法。你在用嗎? –
所以在storybaord中這個滾動視圖應該重疊所有內容嗎? –