iOS 7 UIToolBar Overriding With Status Bar

前端 未结 6 1458
你的背包
你的背包 2020-12-06 07:20

I have upgraded my project from iOS 6 to iOS 7 but there seems a little problem. The status bar and a tool bar is overriding and very close to each other. The tool bar was e

6条回答
  •  甜味超标
    2020-12-06 07:58

    Remember that you shouldn't just move things down in IB for two reasons:

    1. Not compatible with iOS 6
    2. Won't extend the top bar background effect under the status bar

    What not to do...

    So, if you want to iOS6 & iOS7 compatibility, you could add a conditional for objects that require customization in ViewDidLoad. Caveat being this is a last case scenario - always try to remedy it with autolayout / IB first:

    #import 
    
    #ifdef __IPHONE_7_0
    
            CGRect barFrame = topBar.frame;
            barFrame.origin = CGPointMake(0, [UIApplication sharedApplication].statusBarFrame.size.height);
            [topBar setFrame:barFrame];
    
            // move other stuff around too
    
        #endif
    

    And set your bar delegate much like Luniz above,override positionForBar to .

    topBar.delegate = self;
    
    - (UIBarPosition)positionForBar:(id )bar {
    
        return UIBarPositionTopAttached;
    }
    

提交回复
热议问题