Reputation: 4066
I've been trying to create a Navigation Bar with a background image but have been running into a lot of trouble.
Two problems that I can't solve:
1) The pink line under the image
2) The back button should be moved up a little
This is the code I use to place the image:
class CustomNavController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
if let img = UIImage(named: "topbar60.png"){
UINavigationBar.appearance().setBackgroundImage(img, for: .default)
}
}
}
If anyone is feeling really charitable you can just plug the image and Navigation Controller subclass into an empty project to try to solve this.
Thanks a lot for any help.
Upvotes: 0
Views: 100
Reputation: 3802
For your first question, You are getting the pink underline because the image's height is 60 while the navigation bar's height is 64. If you change your image's height to 64, the pink line will disappear.
As for your second question, it is a bit more complicated. Your best bet would be probably to create a custom UIBarButtonItem
Upvotes: 1