您的位置:首页 > 产品设计 > UI/UE

UINavigationController以及UITabBarController背景图片和文字的设置

2016-01-04 13:12 423 查看
 系统版本大于7.0以后,再用到在iOS
7中,苹果引入了一个新的属性,叫做
[UIViewController
setEdgesForExtendedLayout:]
,它的默认值为
UIRectEdgeAll
。当你的容器是navigation
controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。

 if (OSVersionIsAtLeastiOS7()) {  

        if ([self respondsToSelector:@selector(edgesForExtendedLayout)])  

        {  

            self.edgesForExtendedLayout = UIRectEdgeNone;  

        }  

    }  

//修改tabbarItem的字体颜色

[[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
grayColor],

                                                       
NSFontAttributeName:[UIFont
systemFontOfSize:10]

                                                       
}

                                             forState:UIControlStateNormal];

    [[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
redColor],

                                                        
NSFontAttributeName:[UIFont
systemFontOfSize:10]}

                                             forState:UIControlStateSelected];

 

//设置tabbar背景图片

    [[UITabBar
appearance] setBackgroundImage:[UIImage
imageNamed:@"sixin_bottom_bg"]];

    

    //去除tabbar在iOS7显示的时候在顶部出现的黑线

    [[UITabBar
appearance] setShadowImage:[[UIImage
alloc] init]];

  //导航栏字体设置

    self.navigationBar.titleTextAttributes =
@{

                                               NSFontAttributeName: [UIFont 
boldSystemFontOfSize:20.0],

                                               NSForegroundColorAttributeName: [UIColor
colorWithHexString:@"#2c2c2b"],

                                               };

 //导航栏返回按钮颜色

    self.navigationBar.tintColor =
SBTextColor;

    //market_returns_icon@2x

    //navigationBar的背景颜色

    self.navigationBar.barTintColor = [UIColor
whiteColor];

    //导航栏背景

    [[UINavigationBar
appearance] setBackgroundImage:[UIImage
createImageWithColor:[UIColor
whiteColor]] forBarMetrics:UIBarMetricsDefault];

 /**

     *  电池栏颜色修改 info.plist
里面
添加  View controller-based status bar appearance  =  NO

     */

    [[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];//状态栏颜色
      }

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UINavigationControll