首页 > 其他 > 详细

UITextAttributeTextColor 的替换方法

时间:2016-01-07 22:45:41      阅读:258      评论:0      收藏:0      [点我收藏+]

UITextAttributeTextColor 的替换方法  

     UITextAttributeTextColor 已经在iOS7.0以后被推荐使用了,UITextAttributeTextColor = deprecated in iOS 7.0,改为推荐使用UITextAttributeTextColor类来代替,具体替换方法以及相关示例代码如下:

  - 使用UITextAttributeTextColor的方法源代码如下所示:

    // 3.设置导航栏主题
    UINavigationBar *navBar = [UINavigationBar appearance];
    // 设置背景图片
    [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
    // 设置标题文字颜色和字体大小
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[UITextAttributeTextColor] = [UIColor whiteColor];
    attrs[UITextAttributeFont] = [UIFont systemFontOfSize:16];
    [navBar setTitleTextAttributes:attrs];

 

 

  - 使用UITextAttributeTextColor类代替上述代码如下:

    // 3.设置导航栏主题
    UINavigationBar *navBar = [UINavigationBar appearance];
    // 设置背景图片
    [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
    // 设置标题文字颜色和字体大小
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont systemFontOfSize:16], NSFontAttributeName,nil]];

 

如有不对之处,请敬请指针。

UITextAttributeTextColor 的替换方法

原文:http://www.cnblogs.com/wangmaster/p/5111436.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!