IOS7 after the navigationbar.translucent default is yes, the coordinates 0 point default at (0,0) point when opaque navigationbar. Translucent=no, 0 point coordinates in (0 , 64);
- (void) Setnavigationbar {Self. Automaticallyadjustsscrollviewinsets =NO;Self. edgesforextendedlayout = Uirectedgetop;Top StartSelf. Navigationcontroller. Navigationbar. Translucent =YES;Navigation bar Transparency [Self. Navigationcontroller. Navigationbar setbackgroundimage:[UIImage imagenamed:@"Barpic1"] forbarmetrics:uibarmetricsdefault];Add background color (picture) (main if you want to set the navigation bar to transparent) • Just use a transparent picture.)Set the navigation bar text to WhiteSelf. Navigationcontroller. Navigationbar. titletextattributes=[nsdictionary dictionarywithobjectsandkeys:[uicolor whitecolor],uitextattributetextcolor, Nil]; //Set Back button to white [self. Navigationcontroller. Navigationbar settintcolor:[Uicolor Whitecolor]; //Set Back button unity to return uibarbuttonitem *item = [[uibarbuttonitem alloc] initwithtitle:@"return" style: Uibarbuttonitemstyleplain Target:nil action:Nil]; Self . Navigationitem. Backbarbuttonitem = Item;}
Remove the split line below the navigation barif ([Self. Navigationcontroller. Navigationbar Respondstoselector:@selector (setbackgroundimage:forbarmetrics:)]) {Nsarray *list=Self. Navigationcontroller. Navigationbar. subviews; For (theID obj in list) { if ([obj iskindofclass:[Uiimageview class]]) { Uiimageview *imageview= (uiim Ageview *) obj; nsarray *list2=imageview. subviews; For (ID obj2 in list2) { if ([Obj2 iskindofclass:[Uiimageview class]]) { Uiimageview *imageview2= (Uiimageview *) obj2; ImageView2. hidden=YES;}} } }
Remove the navigation bar split line and set the background color of the navigation bar