JP Aquino
JP Aquino

Reputation: 4066

Remove line under custom navigation bar

I've been trying to create a Navigation Bar with a background image but have been running into a lot of trouble.

enter image description here

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)
        }
    }
}

Original bar image: enter image description here

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

Answers (1)

Malik
Malik

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

Related Questions