ios - How to use asset catalog for navigation bar background image? -


i use asset catalog 2x images iphone5 , 6 described in docs:

enter image description here

image navigation bar background 750x128 (750 x 44 * 2 + 20 * 2) because want cover status bar. 750 iphone6 resolution width. bg image setting:

self.navigationcontroller?.navigationbar     .setbackgroundimage(uiimage(named: "nav_bar_bg"), forbarmetrics: .default) 

let's @ result:

enter image description here

ok. iphone5:

enter image description here

not ok. how can downscale without removing background image asset catalog? don't want hardcode it. it's annoying iphone5 , 6 resources can't separated.

any suggestions? thanks

sorry, didn't notice uinavigationbar thing... can change resize of picture used in background making picture stretchable. way can use picture fits smaller devices (the iphone5 in example) , keep picture centered in iphone 6.

another more convoluted solution subclass navbar altogether , rewrite way picture drawn.


you should use nslayoutconstraints (leading, top , trailing), , set uiimageview content fit. way won't need change image, automatically scaled application.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -