ios - 使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样

标签 ios swift storyboard uisegmentedcontrol uipageviewcontroller

在我目前正在开发的应用程序中,我在两个 UITableViewController 之间切换,UINavigationBar 内有一个 UISegmentedControl。新的 Apple Music 有一个非常简洁的效果,用户可以在 UIPageViewController 内部的 UIViewController 之间切换。关联的 UISegmentedControl 对此进行了平滑调整。基本的 Storyboard设置或代码库应该如何实现这样的目标?

UIPageViewController and UISegmentedControl in Apple Music App

最佳答案

您需要按以下方式使用 uipageviewcontroller 和 uisegmentedcontrol

  1. 使用 uipageviewcontroller 并查看本教程以了解其集成 http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/

  2. 之后,如果您只想在用户单击 uisegment 按钮时执行两个 View 之间的转换,则不要实现此委托(delegate)

    • (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController

    • (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController

  3. 设置过渡样式为滚动

  4. 现在您需要自定义 uisegmentedcontrol 以提供按下事件动画

  5. 在按钮的点击事件上执行设置您需要使用此代码显示的 View Controller

[youPagecontrollerObject setViewControllers:object direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];

6 构建并运行

关于ios - 使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31492329/

相关文章:

ios - UITextView 表情符号字符限制计数不正确

swift - 无法将类型 'Int' 的值转换为预期参数类型 'Bool'

ios - 在基本本地化中找不到 main.storyboard 字符串

iphone - 无法使用模型 segue 在 View 上设置标签

iphone - 有人可以解释一下多点触控缩放是否适用于 UITextView 或 UIScrollView

ios - swift iOS - NSURLSession 无法正确下载多个文件

objective-c - 在 iOS6 中记录为联系人存储的每个值

ios - 在 Google Maps iOS API 中创建虚线折线时未解析的标识符

ios - AndClass 是一种类

ios - 如何区分 wR hR 约束变化的方向