简体   繁体   English

在我自己的应用程序中使用“滑动后退”手势

[英]Using the “swipe to go back” gesture in my own app

I'm building an iOS application that requires the same effect seen when swiping back and forth in Safari. 我正在构建一个iOS应用程序,该应用程序需要在Safari中来回滑动时看到的相同效果。

When swiping to go back, the foreground panel moves out of the way but the panel in the back is moving a bit as well. 滑动后退时,前景面板会移开,但背面的面板也会移动一点。 Very similar to the horizontal scrolling that exists in the Yahoo Weather app. 与Yahoo Weather应用程序中的水平滚动非常相似。

Is this a built-in control with iOS 7? 这是iOS 7的内置控件吗? I'm seeing it in a lot of places but can't quite figure out how to do it. 我在很多地方都看到了它,但是还不太清楚该怎么做。

I think there are 2 UIScrollView working together, when the user scrolls on the foreground UIScrollView , you should move the background UIScrollView , something like this: 我认为有2个UIScrollView一起工作,当用户在前景UIScrollView上滚动时,应移动背景UIScrollView ,如下所示:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if ([scrollView isEqual:self.scrollViewForeground]) {

        CGPoint offset = self.scrollViewForeground.contentOffset;
        offset.x = offset.x * 0.5;
        [self.scrollViewBackground setContentOffset:offset];
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM