ios - UINavigationBar background - how to cover all sizes, resolutions and devices? -


i have following code works fine setting background image:

[self.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed: @"navbar_bg.png"] forbarmetrics:uibarmetricsdefault]; 

my question is, xcode6, ios8/9, iphone 5, 6, 6+, ipad, etc, how make sure cover devices, widths , resolutions, make sure background image fills navigation bar correctly?

i have seen other questions on , various other sites, have been 2-4 years old, , don't mention or cover latest device widths , resolutions.

i want use background image in navigation bar, need make sure looks on possible devices.

all have have 3 versions of image in asset catalogue. first in size need second twice size , third 3 times size. xcode put right image on right device.

alternatively can put vectorial image , @ complie time xcode generate 3 images on fly.

for navigation bar need separate images portrait , landscape. can write this:

uiimage *portraitimage = [uiimage imagenamed:@"test_bar_portrait.png"]; uiimage *landscapeimage = [uiimage imagenamed:@"test_bar_landscape.png"]; [[uinavigationbar appearance] setbackgroundimage:portraitimage forbarmetrics:uibarmetricsdefault]; [[uinavigationbar appearance] setbackgroundimage:landscapeimage forbarmetrics:uibarmetricslandscapephone]; self.navigationcontroller.navigationbar.autoresizingmask = uiviewautoresizingflexibletopmargin; 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -