• 爱情文章
  • 亲情文章
  • 友情文章
  • 生活随笔
  • 校园文章
  • 经典文章
  • 人生哲理
  • 励志文章
  • 搞笑文章
  • 心情日记
  • 英语文章
  • 范文大全
  • 作文大全
  • 新闻阅读
  • 当前位置: 山茶花美文网 > 励志文章 > 正文

    [iOS中UIAppearance使用] 如何使用iOS12

    时间:2020-05-26来源:山茶花美文网 本文已影响 山茶花美文网手机站

    iOS5及其以后提供了一个比较强大的工具UIAppearance,我们通过UIAppearance设置一些UI的全局效果,这样就可以很方便的实现UI的自定义效果又能最简单的实现统一界面风格,它提供如下两个方法。

    + (id)appearance

    这个方法是统一全部改,比如你设置UINavBar的tintColor,你可以这样写:[[UINavigationBar appearance] setTintColor:myColor];

    + (id)appearanceWhenContainedIn:(Class <>)ContainerClass,...

    这个方法可设置某个类的改变:例如:设置UIBarButtonItem 在UINavigationBar、UIPopoverController、UITabbar中的效果。就可以这样写

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

    请注意*使用appearance设置UI效果最好采用全局的设置,在所有界面初始化前开始设置,否则可能失效。

    支持UIAppearance协议的类可以访问appearance selector ,它为receiver返回appearance proxy,我么可以给proxy发一些消息,诸如setTintColor:等

    但是它并不是支持所有的UI类。下面列出它支持的类

    1.UIActivitiIndicatorView

    2.UIBarButtonItem

    3.UIBarItem

    4.UINavgationBar

    5.UIPopoverControll

    6.UIProgressView

    7.UISearchBar

    8.UISegmentControll

    9.UISlider

    10.UISwitch

    11.UITabBar

    12.UITabBarItem

    13.UIToolBar

    14.UIView

    15.UIViewController

    • [iOS中UIAppearance使用] 如何使用iOS12 相关文章:
    • 爱情文章
    • 亲情文章
    • 友情文章
    • 随笔
    • 哲理
    • 励志
    • 范文大全