i set custom navigationbar kvo in ios8,and custom navigationbar setbackgroundimage.
i found viewcontoller.view.frame.origin.y
64 , viewcontroller navigation's rootviewcontroller.
why viewcontoller.view.frame.origin.y
64 in ios 8?
the following demo code:
@implementation viewcontroller - (void)viewdidload { [super viewdidload]; uinavigationbar *temp = [[uinavigationbar alloc]init]; [temp setbackgroundimage:[uiimage imagenamed:@"navbar_bg"] forbarmetrics:uibarmetricsdefault]; [self.navigationcontroller setvalue:temp forkey:@"navigationbar"]; } - (void)viewdidappear:(bool)animated { nslog(@"view : %@",self.view); // print :<uiview: 0x7ff8fa72cfa0; frame = (0 64; 375 603); autoresize = rm+bm; layer = <calayer: 0x7ff8fa72b2b0>> }
if cancel [temp setbackgroundimage:[uiimage imagenamed:@"navbar_bg"] forbarmetrics:uibarmetricsdefault];
, view.origin.y
0
correctly.
what should correctly set custom navigationbar
setbackgroundimage , keep self.view.orgin
(0,0)
?
you can set title of navigationcontroller.navigationitem
instead of setting uinavigationbar
, providing kvo.
- (void)viewdidload { [super viewdidload]; uiimageview *img = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"navbar_bg"]]; //here can create own custom view , provide title of self.navigationcontroller.navigationitem [self.navigationcontroller.navigationitem settitleview:img]; } - (void)viewdidappear:(bool)animated { nslog(@"view : %@",self.view); // print :<uiview: 0x79ea0a30; frame = (0 0; 375 603); autoresize = w+h; layer = <calayer: 0x79ea0ac0>> }
Comments
Post a Comment