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];  
  • 相关阅读:
    (收藏)Wp7开发中文网站
    (收藏)Andriod中文翻译组
    (1) BlackBerry 环境的配置:安装standalone版的BlackBerry安装包
    (2)把BlackBerry作为插件安装到已有的Eclipse中
    (收藏)一个很不错的编程网站
    Android Architecture
    在Eclipse Android中设置模拟器屏幕大小
    (收藏)C#网站
    (Android) Binding to Data with AdapterView
    ListView 的理解
  • 原文地址:https://www.cnblogs.com/wangliang2015/p/5626420.html
Copyright © 2011-2022 走看看