Remove the navigation bar split line and set the background color of the navigation bar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.