Follow when the iOS-NavigationBar gesture returns

Source: Internet
Author: User

Follow when the iOS-NavigationBar gesture returns
Follow when the iOS-NavigationBar gesture returns

In iOS development, there are sometimes two interfaces in the development process. These interfaces are connected by UINavigationController, And the UINavigationBar is not displayed in the first ViewController, UINavigationBar is displayed on the second page. By default, iOS NavigationBar is fixed when a gesture is returned, and then some gradient displacement and other animations are made. However, if we have NavigationBar on an interface, an animation without such an animation will become ugly. In this case, we want the NavigationBar to move along with the returned result of the Second Interface gesture. Achieve the following effects:

There are two viewcontrollers in this effect. When the second Controller gesture returns, the UINavigationBar follows the Controller. If you only use this effect on the First interface, you only need to add the following code to the two controllers:

// The first ViewControlleroverride func viewWillAppear (animated: Bool) {super. viewWillAppear (animated) // you must use this method here or else there will be problems with self. navigationController ?. SetNavigationBarHidden (true, animated: true)} // The second ViewControlleroverride func viewWillAppear (animated: Bool) {super. viewWillAppear (animated) self. navigationController ?. SetNavigationBarHidden (false, animated: true )}

The above code can only implement the first UINavigationController, the first ViewController, and the second display to achieve the following effect. If you want to achieve the following effects on all the interfaces, You need to customize the transition animation of ViewController. Someone on the Internet has already achieved this effect. If you are interested, download and take a look at it at https://github.com/esonchen/ccslidenavigationtran.

This article is short, just a simple Tip.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.