user3239711
user3239711

Reputation: 649

modifiy and customize the behavior of the UINavigationBar back button

I have a ViewController embeded in a navigationBar. I want the back button in the navigation bar to have the following effect :

Upvotes: 1

Views: 42

Answers (1)

Himanshu
Himanshu

Reputation: 2832

Try like this :-

 override func viewDidLoad() {
       let transparentButton = UIButton()
       transparentButton.frame = CGRectMake(0, 0, 50, 40)
       transparentButton.backgroundColor = UIColor.orangeColor()
       transparentButton.addTarget(self, action:"backAction:", forControlEvents:.TouchUpInside)
       self.navigationController?.navigationBar.addSubview(transparentButton)
    }

And the function is

 func backAction(sender:UIButton) {
     // check your condition
 }

Upvotes: 1

Related Questions