onkar onkar - 1 year ago 87
Swift Question

How do I get back button effect (<)

I am writing an app , where I want custom back effect of the default OS. Like the system which is giving with Settings (

<
)
< Icon


Refer this image (I want the effect like Settings with the
<
)

enter image description here

I already have the functionality, I just want the look and feel.

Effect what I am getting.
I have tried the following
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "cancel")

Also, I have tried adding it via Storyboard. How do I get it ?

enter image description here

Answer Source

Use the backBarButtonItem and you will get right effect.

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "cancel")

Also, you make sure

self.navigationItem.backBarButtonItem will be shown only after your have pushed another one view to navigation stack, controlled by self.navigationController, if no left button on navigation bar is displayed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download