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
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)
You could try this:
let barImage = yourUIImage.stretchableImage(withLeftCapWidth: 0, topCapHeight: 0)
self.navigationController?.navigationBar.setBackgroundImage(barImage, for: .default)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.