IOS7 Navigation bar Adaptation

Source: Internet
Author: User

Problem:

In Appdelegate

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {

Viewcontroller *vc=[[viewcontroller Alloc]init];

Uinavigationcontroller *nav=[[uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC];

Nav.view.backgroundColor = [Uicolor Bluecolor];

Self.window.rootviewcontroller=nav;

return YES;

}

In the Viewcontroller:

-(void) viewdidload {[Super viewdidload];//if ([Self respondstoselector: @selector (setedgesforextendedlayout:)])// {//Self.edgesforextendedlayout = uirectedgenone;//}//Self.navigationController.navigationBar.translucen    T=no;    Self.view.backgroundcolor=[uicolor Clearcolor]; Uiscrollview *segmentscorllview = [[Uiscrollview alloc] Initwithframe:cgrectmake (0, 164, Self.view.frame.size.width,    44)];    Segmentscorllview.backgroundcolor=[uicolor Greencolor];    UIButton *button = [UIButton buttonwithtype:uibuttontypecustom];    [Button setframe:cgrectmake (0, 0, 50, 44)];    [Button settitle:@ "AAA" forstate:uicontrolstatenormal];    [Button Settitlecolor:[uicolor Bluecolor] forstate:uicontrolstateselected];    [Button Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal];    Button.backgroundcolor = [Uicolor Browncolor];    [Button.titlelabel Setfont:[uifont systemfontofsize:15];    [Segmentscorllview Addsubview:button]; [Self.view addsubview:segmentScorllview];} 

Operating effect:

Ideal running Result:

Reason:

The starting coordinates of the screen in IOS7 include the navigation status bar

Workaround:

Remove any comment from the two comments of the above code

IOS7 Navigation bar Adaptation

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.