简体   繁体   中英

Navigation Bar Back Button

I have a navigation bar that i want to use this code to change the text but unfortunately the arrow also disappears. So I added a less than sign and it worked but the size of it does not match. Is there anyway to fix this issue?

Here is my code

let backButton: UIBarButtonItem = UIBarButtonItem(title: " < Timeline", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
navigationController?.navigationBar.topItem?.leftBarButtonItem = backButton
  1. Create a transparent view.

  2. Add an imageview of fixed size for the arrow image or you can use UILabel too as its working in your case.

  3. Add another UILabel adjacent to your < label or imageview. You can use padding to make it look uniform.

  4. Add both label or imageview on your transparent view.

  5. Create UIBarButtonItem of your customView and then add it to your navBar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM