2

I would like to have a custom Navigation Controller, I did a lot of search, I read many questions on Stack, etc. But I still don't know how to do that.

I would like to do that Navigation Bar:

enter image description here

It's really difficult to add icons, and even more if I want that these can move. It would be the same effect than Instagram (When I click the button, the icon is rotating).

PHASE 1:

enter image description here

PHASE 2:

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
KevinB
  • 2,454
  • 3
  • 25
  • 49

2 Answers2

0

You only need to add an image button to the navigation bar title

let button = UIButton.init(type: .custom)
button.setImage(UIImage.init(named: "YourImage"), for: UIControlState.normal)
button.frame = CGRect.init(x: 0, y: 0, width: 30, height: 30)
button.addTarget(self, action: #selector(self.onButtonClicked), for: .touchUpInside)
self.navigationItem.titleView = button
Lawliet
  • 3,438
  • 2
  • 17
  • 28
  • Thanks for that help ! I posted above the problem caused by this method. Do you have an idea ? – KevinB May 15 '17 at 10:10
  • Note sure what is your issue. If the standard of 30w-30h works why do you have to change it to 15w-15h? – Lawliet May 15 '17 at 10:39
0

I found a solution !

It was pretty simple (Swift 3):

button.imageView?.contentMode = .scaleAspectFit
KevinB
  • 2,454
  • 3
  • 25
  • 49