zoukankan      html  css  js  c++  java
  • UIBarButtonItem关于全局修改,局部修改

    工具类UIAppearance可以统一设置控件的风格,当调用appearance方法时他会拿到相对应的控件(你用什么控件调用appearace方法,他就会返回什么控件),然后你可以设置统一主题(风格)

    + (id)appearance
    + (id)appearanceWhenContainedIn:(Class <>)ContainerClass,...
     
    第一个方法是统一全部改,比如你设置UINavigationBar 的tintColor,你可以这样写:
    [[UINavigationBar appearance] setTintColor:myColor];

    /** 这样写之后,所有的 UINavigationBar 的tintColor的颜色都为myColor */

    第二个方法是当出现在某个类的出现时候才会改变

    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIPopoverController class], nil] setTintColor:myPopoverNavBarColor];

    1.修改背景: 
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:leftButton  
                                                          forState:0  
                                                        barMetrics:UIBarMetricsDefault];  
     

    2.修改字体,阴影,字体颜色
    NSDictionary* textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:  
                                       BAR_BUTTON_TITLE_TEXT_COLOR,UITextAttributeTextColor,  
                                       BAR_BUTTON_TITLE_FONT,UITextAttributeFont,  
                                       BAR_BUTTON_TITLE_SHADOW_COLOR,UITextAttributeTextShadowColor,  
                                       [NSValue valueWithCGSize:CGSizeMake(1, 1)],UITextAttributeTextShadowOffset,  
                                       nil];  
      
       [[UIBarButtonItem appearance] setTitleTextAttributes:textAttributes forState:0];  

    3,修改UIBarButtonItem中文字的位置:
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(2, -1)  
                                                           forBarMetrics:UIBarMetricsDefault];  
  • 相关阅读:
    response.redirect on asp.net is a 302 jump action
    什么吃掉了我的硬盘?
    百度流量统计将会影响搜索的排名
    发邮件 python
    bottle template usage
    想提神,喝中药,咖啡可可没用的
    企业退信的常见问题?
    用UnixBench测试VPS性能 判别是否值得购买
    域名注册及免费空间and企业邮箱
    LNMP一键安装包是什么?
  • 原文地址:https://www.cnblogs.com/wangliang2015/p/5626420.html
Copyright © 2011-2022 走看看