`UINavigationBar` and `UINavigationItem` are commonly used controls in iOS development. Today I will introduce six tips about the navigation bar. 1. Set the navigation bar title self.title=@"iOS Development: iOSDevTip"; How to set it up: [self.navigationController.navigationBarsetBarStyle:UIBarStyleBlack]; `UIBarStyle` style: typedefNS_ENUM(NSInteger,UIBarStyle){ UIBarStyleDefault = 0, UIBarStyleBlack = 1, UIBarStyleBlackOpaque =1,//Deprecated.UseUIBarStyleBlack UIBarStyleBlackTranslucent=2,//Deprecated.UseUIBarStyleBlackandsetthetranslucentpropertytoYES }; `UIBarStyleDefault` is the default style, `UIBarStyleBlack` is black and opaque. `UIBarStyleBlackOpaque` and `UIBarStyleBlackTranslucent` are already deprecated. If you want to set the navigation bar transparent, you can add the following code: self.navigationController.navigationBar.translucent=YES; self.navigationItem.title=@"test"; The dumber way is: self.navigationItem.title=@""; You can also set it like this: [[UIBarButtonItemappearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0,-60)forBarMetrics:UIBarMetricsDefault]; self.navigationItem.leftBarButtonItem=[[UIBarButtonItemalloc]initWithTitle:@"back"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(back:)]; -(void)back:(id)sender { [self.navigationControllerpopViewControllerAnimated:YES]; } 6. What to do if the left swipe back gesture fails If you set `leftBarButtonItem` as in the previous step, the left swipe back gesture will be invalid. Just set the `UIGestureRecognizerDelegate` proxy: self.navigationController.interactivePopGestureRecognizer.delegate=self; The above are six tips about the navigation bar. For more iOS development related technologies, please follow my WeChat public account iOS Development: **iOSDevTip** |
<<: Technical interview strategies worth reading
For operators, SOP capability is a basic capabili...
What is the price for customizing Bijie catering ...
1. Profit VS registration volume? I recently saw ...
There can be no room for falsehood in scientific ...
The WeChat team issued an announcement stating th...
For operational promotion, the most important thi...
"It is foreseeable that an ice age is taking...
Have you posted today? When Tadpole is working ov...
This article is also known as " Xiaomi App S...
What is the world like for the blind and the deaf...
Chun Ge, the painter, introduces the basic practi...
Intel occupies most of the world's graphics c...
In Journey to the West, Sun Wukong's golden h...
At 9:56 am Beijing time on April 16, 2022, the ret...
It is so refreshing to go to the beach to play in...