UIAppearance

#pragma mark - 定制全局的Bar

-(void)customAllBar{

//定制所有的Bar的背景颜色和标题外观

[UINavigationBar appearance].barTintColor = [UIColor lightGrayColor];

//NSDictionary :@{属性名:对象}

[UINavigationBar appearance].titleTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:40],NSForegroundColorAttributeName : [UIColor yellowColor]                                                       };

}

#pragma mark - 定制全局的ToolBarButtonItem

-(void)customToolBarButtonItem{

//修改的是NavigationBar和Toolbar上得所有不是图片的NavigationItem的背景

//[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"header_bg"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

//修改所有在UIToolbar出现过的UIBarButtonItem把他们的背景变成Blue

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIToolbar class]] ] setTintColor:[UIColor blueColor]];

}

时间: 2024-08-04 10:17:48

UIAppearance的相关文章

转iOS UIAppearance使用详解

iOS5及其以后提供了一个比较强大的工具UIAppearance,我们通过UIAppearance设置一些UI的全局效果,这样就可以很方便的实现UI的自定义效果又能最简单的实现统一界面风格,它提供如下两个方法. + (id)appearance 这个方法是统一全部改,比如你设置UINavBar的tintColor,你可以这样写:[[UINavigationBar appearance] setTintColor:myColor]; + (id)appearanceWhenContainedIn:

[转]iOS UIAppearance使用详解

在iOS 5以前,自定义原生控件的外观并没有原生支持,因此开发人员感觉很麻烦.开发人员经常面临的问题是修改一个控件所有实例的外观.解决这个问题的正确方法是重写一遍控件.但由于这么做非常费时,一些开发人员开始覆盖或混写一些方法,如drawRect:. 从iOS 5开始,苹果通过两个协议(UIAppearance和UIAppearanceContainer)规范了对许多UIKit控件定制的支持.所有遵循UIAppearance协议的UI控件通过定制都可以呈现各种外观.不仅如此,UIAppearanc

UIAppearance定制控件的默认外观

一,概述 控件的外观,受到tint color,background image, background color等属性的共同影响,通常要修改某个控件对象的外观,就去调用上面属性的相关setter方法(或者其他可以修改它们的方法)就可以了.但是,如果希望整个app中的控件都保持一致的风格,比如所有button的风格(指的是大小,背景图,形状等)都一样,那么一个一个去重复设置每个button的风格,就显得太麻烦了.如果可以给Button类设定一个默认外观,就方便多了.appearance pro

iOS 使用UI控件的外观协议UIAppearance进行设置默认UI控件样式

在iOS开发中,经常会对UINavigationBar的样式进行全局样式.采用的设置方式有两种: 第一种,采用方式如下: [UINavigationBar appearance] 这种是对一类对象的默认全局外观样式设置,它对设置时机有要求. 通常需要在UIWindow的viewlayout之前.错过了时机后,设置是没有效果的. 可以选择在下面方法内设置: - (BOOL)application:(UIApplication *)application didFinishLaunchingWith

Objective - C学习笔记:UIView的使用方法

1.1 - (void)layoutSubviews; * 当一个控件的frame发生改变的时候就会自动调用 * 一般在这里布局内部的子控件(设置子控件的frame) * 一定要调用super的layoutSubviews方法 1.2 - (void)didMoveToSuperview; * 当一个控件被添加到父控件中就会调用 1.3 - (void)willMoveToSuperview:(UIView *)newSuperview; * 当一个控件即将被添加到父控件中会调用 @interf

[转]Appearance

Appearance Proxies UIAppearance是一个协议,UIView默认已经遵守了这个协议. @protocol UIAppearance <NSObject> @interface UIView : UIResponder <NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem, UITraitEnvironment, UICoordinateSpace, UIFocusEnvironment>

设置控件全局显示样式 appearance

iOS5及其以后提供了一个比较强大的工具UIAppearance,我们通过UIAppearance设置一些UI的全局效果,这样就可以很方便的实现UI的自定义效果又能最简单的实现统一界面风格,它提供如下两个方法. + (id)appearance 这个方法是统一全部改,比如你设置UINavBar的tintColor,你可以这样写:[[UINavigationBar appearance] setTintColor:myColor]; + (id)appearanceWhenContainedIn:

实时显示iOS编写UI代码效果

编写iOS应用UI的方式大概有两种,一种是Storyboard/Xib,另一种是手写代码.采用Storyboard/Xib方式组织UI,由于提供可视化的特性,只要从UI库中拖动UI控件,便可以显示结果,极大地提高开发速度.但面临一个问题就是多人协作开发,由于所有的UI都放在同一个Storyboard文件中,使用Git/SVN合并代码就会出现冲突.多人协作开发还不是主要问题,有人提出可以创建多个Storyboard来分开UI编写,而Storyboard/Xib最主要问题是代码复用性比较差.所以有些

[翻译] DZNSegmentedControl

DZNSegmentedControl A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile. 一个UISegmentedControl的子类,用以扩展UISegmentedControl的功能,可以用在展示用户的信息上. Features Customizable control with tint color, font, sizes an