ios - Background image of opaque navigation bar is rendered incorrectly on iPhone 6 -


when set background image method

setbackgroundimage:forbarmetrics: 

it's rendered on iphone 6

navigation bar on iphone 6

if set navigation bar translucent, it's stretched normally. enter image description here

@implementation ohcnavigationbar  - (id)initwithcoder:(nscoder *)adecoder {     if(self = [super initwithcoder:adecoder]) {         [self setupgradient];     }        return self; }  - (instancetype)initwithframe:(cgrect)frame {     if(self = [super initwithframe:frame]) {         [self setupgradient];     }     return self; }   - (void)setupgradient {     uiimage *gradientimage = [uiimage imagenamed:@"navigationbarbackground.png"];    [self setbackgroundimage:gradientimage forbarmetrics:uibarmetricsdefault]; }  @end 

you can set uinavigationbar background image non repeat mode setting edge 0.

uiimage *gradientimage32 = [[uiimage imagenamed:@"bkg_top_header_default.png"] resizableimagewithcapinsets:uiedgeinsetsmake(0, 0, 0, 0)]; [[uinavigationbar appearance] setbackgroundimage:gradientimage32                                    forbarmetrics:uibarmetricsdefault]; [self.navigationcontroller.navigationbar setbackgroundimage:gradientimage32 forbarmetrics:uibarmetricsdefault]; 

update 1:

- (void)setupgradient {     uiimage *gradientimage = [[uiimage imagenamed:@"navigationbarbackground.png"] resizableimagewithcapinsets:uiedgeinsetsmake(0, 0, 0, 0)  resizingmode:uiimageresizingmodestretch];      [self setbackgroundimage:gradientimage forbarmetrics:uibarmetricsdefault]; } 

may you.

enjoy coding !!


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -