iOS 设置NavigationBar的样式

来源:互联网 发布:thinkphp app源码 编辑:程序博客网 时间:2024/05/21 06:17

#pragma mark - 设置NavigationBar的样式

- (void)setNavigationBarStyle

{

    UINavigationBar *defaultNavigationBar = [UINavigationBarappearance];

    //1 导航栏的颜色

    [defaultNavigationBar setBarTintColor:[UIColorwhiteColor]];

    //2 navigationBarItem文字的颜色,按钮等颜色,不是title的颜色

    [defaultNavigationBar setTintColor:[UIColorredColor]];

    

    //3 导航栏文字的主题,#33333351,51,51

    [defaultNavigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(51,51, 51), NSFontAttributeName:[UIFontsystemFontOfSize:18.0]}];

    

    //4 所有返回按钮样式

    UIBarButtonItem *defaultBarButtonItem = [UIBarButtonItemappearance];

    UIImage *backButtonImage = [[UIImageimageNamed:@"back"]resizableImageWithCapInsets:UIEdgeInsetsMake(0,30, 0, 0)];//上左下右在该圈内的内容可拉伸

    [defaultBarButtonItem setBackButtonBackgroundImage:backButtonImageforState:UIControlStateNormalbarMetrics:UIBarMetricsDefault];

    //5 将返回按钮的文字position设置不在屏幕上显示

    [defaultBarButtonItem setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin,NSIntegerMin)forBarMetrics:UIBarMetricsDefault];

    

}


0 0
原创粉丝点击