Reputation: 693
I am setting a background image on the uinavigationbar, but the image is repeating itself. I don't want that the image repeats itself. Can anyone help me in this.
Here is the code for setting the background image:
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "Image_Name")), for: .default)
Here is the screenshot of my navigation bar:
See the circled portion, there is a line in between and after that line the image starts repeating itself.
Thanks In Advance
Upvotes: 1
Views: 600
Reputation: 2186
You could try this:
let barImage = yourUIImage.stretchableImage(withLeftCapWidth: 0, topCapHeight: 0)
self.navigationController?.navigationBar.setBackgroundImage(barImage, for: .default)
Upvotes: 0
Reputation: 665
Set resizable image with resizing mode. try this code.
let image = //your image
let barImage = image.resizableImage(withCapInsets: .zero, resizingMode: .stretch)
self.navigationController?.navigationBar.setBackgroundImage(barImage, for: .default)
Upvotes: 4