Change UINavigationBar Height

前端 未结 12 1512
囚心锁ツ
囚心锁ツ 2020-11-28 09:26

Can some one tell me how to change the navigation bar height?

Here is what i have so far:

CGFloat navBarHeight = 10;
self.navigationController.navi         


        
12条回答
  •  执笔经年
    2020-11-28 09:56

    Most Simple and Effective Solution is to add a category to navigation bar. (but maybe not the best solution)

    @interface UINavigationBar (CustomHeight)
    
    @end
    
    
    @implementation UINavigationBar (CustomHeight)
    
    - (CGSize)sizeThatFits:(CGSize)size {
        CGRect screenRect = [[UIScreen mainScreen] bounds];
        return CGSizeMake(screenRect.size.width, kNavBarHeightNoStatus);
    }
    @end
    

    knavBarHeightNoStatus is the height of your navbar. We use UIScreen bounds because frame of UINavigationBar is wrong

    PS: Be careful, you can have some issues using it with a SideMenu

提交回复
热议问题