Reputation: 649
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
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