使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样 [英] Smooth Transition with UIPageViewController and UISegmentedControl like in Apple Music App

查看:45
本文介绍了使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In an app that im currently developing im switching between two UITableViewController's with a UISegmentedControl inside the UINavigationBar. The new Apple Music has a very neat effect where a user switches between UIViewController's inside a UIPageViewController. The associated UISegmentedControl adjusts smoothly to this. How should a basic storyboard setup or code base look to achieve something like this?

推荐答案

你需要使用 uipageviewcontroller &uisegmentedcontrol 以如下方式

you need to use uipageviewcontroller & uisegmentedcontrol in the following manner

  1. 采用 uipageviewcontroller &请参阅本教程以了解其集成 http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/

此后,如果您只想在用户单击 uisegment 按钮时执行两个视图之间的转换,请不要实现此委托

after that if you want to perform the transition between two views only when user clicks on the uisegment button the do not implement this delegate

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

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

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

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

将过渡样式设置为滚动

现在您需要自定义 uisegmentedcontrol 以赋予按下事件动画

now you need to customise the uisegmentedcontrol to give the pressing event animation

在按钮的点击事件上执行设置您需要使用此代码显示的视图控制器

on the click event of the button perform set the view controller you need to display with this code

[youPagecontrollerObject setViewControllers:object 方向:UIPageViewControllerNavigationDirectionForward 动画:YES 完成:nil];

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

6 构建 &运行

6 build & run

这篇关于使用 UIPageViewController 和 UISegmentedControl 平滑过渡,就像在 Apple Music App 中一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆