1976年贪婪的嘴唇,韩国少妇激三级做爰2023电影,久久久久久精品国产三级涨奶,妖精漫画在线观看免费漫画下拉式

iOS中UIAppearance使用
來源:易賢網 閱讀:1257 次 日期:2015-02-10 13:40:34
溫馨提示:易賢網小編為您整理了“iOS中UIAppearance使用”,方便廣大網友查閱!

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

具體UI外觀修改如下:

1.修改導航欄背景

代碼如下:

UINavigationBar * appearance = [UINavigationBar appearance];

UIImage *navBackgroundImg =[UIImage imageNamed:@"navBg.png”];

[appearance setBackgroundImage:navBackgroundImgforBarMetrics:UIBarMetricsDefault];

2.標簽欄(UITabbar)

代碼如下:

UITabBar *appearance = [UITabBar appearance];

//設置背景圖片

[appearance setBackgroundImage:[UIImage imageNamed:@"tabbar_bg.png"]];

//門置選擇item的背景圖片

UIImage * selectionIndicatorImage =[[UIImageimageNamed:@"tabbar_slider"]resizableImageWithCapInsets:UIEdgeInsetsMake(4, 0, 0,0)] ;

[appearance setSelectionIndicatorImage:selectionIndicatorImage];

3.分段控件(UISegmentControl)

代碼如下:

UISegmentedControl *appearance = [UISegmentedControl appearance];

//Segmenteg正常背景

[appearance setBackgroundImage:[UIImage imageNamed:@"Segmente.png"]

forState:UIControlStateNormal

barMetrics:UIBarMetricsDefault];

//Segmente選中背景

[appearance setBackgroundImage:[UIImage imageNamed:@"Segmente_a.png"]

forState:UIControlStateSelected

barMetrics:UIBarMetricsDefault];

//Segmente左右都未選中時的分割線

//BarMetrics表示navigation bar的狀態,UIBarMetricsDefault 表示portrait狀態(44pixel height),UIBarMetricsLandscapePhone 表示landscape狀態(32pixel height)

[appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]

forLeftSegmentState:UIControlStateNormal

rightSegmentState:UIControlStateNormal

barMetrics:UIBarMetricsDefault];

[appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]

forLeftSegmentState:UIControlStateSelected

rightSegmentState:UIControlStateNormal

barMetrics:UIBarMetricsDefault];

[appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]

forLeftSegmentState:UIControlStateNormal

rightSegmentState:UIControlStateSelected

barMetrics:UIBarMetricsDefault];

//字體

NSDictionary *textAttributes1 = @{UITextAttributeFont: [UIFont systemFontOfSize:18],

UITextAttributeTextColor: [UIColor blueColor],

UITextAttributeTextShadowColor: [UIColor whiteColor],

UITextAttributeTextShadowOffset: [NSValuevalueWithCGSize:CGSizeMake(1, 1)]};

[appearance setTitleTextAttributes:textAttributes1 forState:1];

NSDictionary *textAttributes2 = @{UITextAttributeFont: [UIFont systemFontOfSize:18],

UITextAttributeTextColor: [UIColor whiteColor],

UITextAttributeTextShadowColor: [UIColor blackColor],

UITextAttributeTextShadowOffset: [NSValuevalueWithCGSize:CGSizeMake(1, 1)]};

[appearance setTitleTextAttributes:textAttributes2 forState:0];

4.UIBarbutton

注意:UIBarbutton有leftBarButton,rightBarButton和backBarButton,其中backBarButton由于帶有箭頭,需要單獨設置。

barButton背景設置是ios6.0及以后的,而backbutton是ios5.0及以后的,這里要注意!

代碼如下:

//修改導航條上的UIBarButtonItem

UIBarButtonItem *appearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];

//設置導航欄的字體包括backBarButton和leftBarButton,rightBarButton的字體

NSDictionary *textAttributes = @{UITextAttributeFont: [UIFontsystemFontOfSize:18],

UITextAttributeTextColor: [UIColorblueColor],

UITextAttributeTextShadowColor: [UIColorwhiteColor],

UITextAttributeTextShadowOffset: [NSValuevalueWithCGSize:CGSizeMake(1, 1)]};

[appearance setTitleTextAttributes:textAttributes forState:1];//forState為0時為下正常狀態,為1時為點擊狀態。

//修改leftBarButton,rightBarButton背景效果

[appearance setBackgroundImage:[UIImage imageNamed:@"navBarButton.png"]

forState:UIControlStateNormal

style:UIBarButtonItemStyleBordered

barMetrics:UIBarMetricsDefault];

[appearance setBackgroundImage:[UIImage imageNamed:@"navBarButton_a.png"]

forState:UIControlStateHighlighted

style:UIBarButtonItemStyleBordered

barMetrics:UIBarMetricsDefault];

//backBarButton需要單獨設置背景效果。只能在ios6.0以后才能用

[appearance setBackButtonBackgroundImage:[UIImage imageNamed:@"nav_bg.png"]

forState:0

barMetrics:UIBarMetricsDefault];

[appearance setBackButtonBackgroundImage:[UIImage imageNamed:@"work.png"]

forState:1

barMetrics:UIBarMetricsDefault];

[appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(2, -1)

forBarMetrics:UIBarMetricsDefault];

5.工具欄(UIToolbar)

UIToolbar *appearance = [UIToolbar appearance];

//樣式和背景二選一即可,看需求了

//樣式(黑色半透明,不透明等)設置

[appearance setBarStyle:UIBarStyleBlackTranslucent];

//背景設置

[appearance setBackgroundImage:[UIImage imageNamed:@"toolbarBg.png"]

forToolbarPosition:UIToolbarPositionAny

barMetrics:UIBarMetricsDefault];

更多信息請查看IT技術專欄

更多信息請查看技術文章
易賢網手機網站地址:iOS中UIAppearance使用
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
主站蜘蛛池模板: 绥江县| 屏东市| 江源县| 沙河市| 察隅县| 阳城县| 天津市| 利辛县| 儋州市| 寿光市| 积石山| 南安市| 太保市| 娱乐| 鄂托克旗| 五华县| 历史| 万全县| 郯城县| 英吉沙县| 平乡县| 延庆县| 富顺县| 江津市| 德昌县| 雅安市| 新邵县| 西华县| 哈密市| 涟水县| 玉山县| 白城市| 元阳县| 冷水江市| 江都市| 始兴县| 古蔺县| 区。| 鄂托克前旗| 双柏县| 根河市|