我想创建一个非常简单的布局,类似条纹的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中这个滚动视图应该重叠所有内容吗? –