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.