IOS "Custom Back button" is used in combination with "system slide"

Source: Internet
Author: User

When we use a custom button to Popviewcontroller and hide the system Navigationbar,

(Self.navigationController.navigationBarHidden = YES;)

The Navigationbar system comes with a slip gesture that does not exist.

Of course we can slide gestures on the current view, but there are bugs, especially views such as ScrollView, TableView, and so on in the view.

Here's a more ingenious way to combine custom backbtn with system side-slip:


-(void) Viewwillappear: (BOOL) animated {    [Super viewwillappear:animated];    Self.navigationController.navigationBar.alpha = 0;    Self.navigationController.navigationBarHidden = YES;} -(void) Viewwilldisappear: (BOOL) animated {    [Super viewwilldisappear:animated];    Self.navigationController.navigationBar.alpha = 1;    Self.navigationController.navigationBarHidden = NO;}

Can be seen, and there is noNavigationbar is hidden, but the transparency is adjusted to 0, the transparency is 0 o'clock Navigationbar will not occupy the position,

But the side-slip feature is still in. In the process, it is found that the backbtn and title of system Navigationbar will appear when half-slide

Therefore, these two items can be set to nil. Note: These settings for Navigationbar are all global in effect,

Be aware of the appropriate processing at different stages of the view life cycle.


In summary, when we want to not use the system Navigationbar view, but only use its slide gesture,

To use the view lifecycle flexibly,

Self.navigationController.navigationBar.alpha = 0; Self.navigationController.navigationBar.alpha = 1;
To switch in a timely manner, the systemNavigationbar'sBackitem and other members may be hidden in time.



IOS "Custom Back button" is used in combination with "system slide"

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.