Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add / use default icons to navigation bar

I want to use some of default iOS icons i.e.
enter image description here

in navigation bar.
Basically I don't know how to call image of that item (directly from native library - I know how to download it and place as custom image:)):

   var myButton:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
   myButton.addTarget(self, action: "reload", forControlEvents: UIControlEvents.TouchUpInside)
   myButton.setImage(???, forState: <#UIControlState#>)
like image 992
pbaranski Avatar asked Sep 14 '15 05:09

pbaranski


People also ask

How do I edit my navigation bar?

From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.


Video Answer


1 Answers

You can use UIBarButtonSystemItem this way:

let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Refresh, target: self, action: "someAction")
navigationItem.leftBarButtonItem = button

Result for leftBarButtonItem:

enter image description here

If you want to set it at right side you can use this code:

navigationItem.rightBarButtonItem = button

Result for rightBarButtonItem:

enter image description here

like image 138
Dharmesh Kheni Avatar answered Oct 01 '22 07:10

Dharmesh Kheni