Nikesh Hyanju
Nikesh Hyanju

Reputation: 190

how to i change the vertical position and size of bar button Item in may navigation controller?

I am working on a project, i have a navigation bar of height 129 now I need to add a bar button Item to my navigation bar. My problem is with the bar button position i want to change the position of bar button item.

This is an image of what is happening: enter image description here

This shows the position for where i want it: enter image description here

Upvotes: 0

Views: 993

Answers (1)

Dmitry Molokov
Dmitry Molokov

Reputation: 185

Very specific situation but you can try set image insets for bar button item.

 let image = UIImage(named: "yourImage")     
 let leftButton = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(self.leftButtonDidPressed))
 leftButton.imageInsets = UIEdgeInsets(top: -64, left: 0, bottom: 0, right: 64)
 self.navigationItem.leftBarButtonItem = leftButton

Upvotes: 1

Related Questions