久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

iOS 5:對 UIAppearance 感到好奇

iOS 5: Curious about UIAppearance(iOS 5:對 UIAppearance 感到好奇)
本文介紹了iOS 5:對 UIAppearance 感到好奇的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

在 2011 年技術(shù)演講中,我看到了一個關(guān)于新 UIAppearance 協(xié)議.那里還沒有很多文檔.我將簡短地總結(jié)一下我記得的內(nèi)容,以解釋我的問題來自哪里:

On the tech talk 2011 I saw a speech about the new UIAppearance protocol. There is not a lot of documentation out there yet. I will shortly summarize what I remember to explain where my question is coming from:

關(guān)于UIAppearance:

到目前為止,您必須在所有應(yīng)用視圖控制器中自定義每個導(dǎo)航欄(工具欄等)屬性.使用新的外觀屬性,您可以只在一個地方為應(yīng)用程序中的所有導(dǎo)航欄執(zhí)行此操作.例如:如果您想自定義導(dǎo)航欄背景圖像,您可以這樣做:

So far you had to customize EVERY navigation bar (toolbar, etc.) property in all your app view controllers. With the new appearance property you can do it in only one place for all navigation bars in your app. For instance: if you want to customize your Navigation bar background image you could do it like this:

[[UINavigationBar appearance] setBackgroundImage:
   [UIImage imageNamed:@"MyImageName"] forBarMetrics:UIBarMetricsDefault]; 

這將設(shè)置應(yīng)用程序中所有導(dǎo)航欄的背景圖像.使用 barMetrics 您可以指定是否要在橫向模式下也使用圖像.

This will set the background image of ALL navigation bars within your application. With the barMetrics you specify whether you want the image to be used also in landscape mode or not.

如果您想指定僅在某些視圖控制器中應(yīng)用的外觀,文檔中還有一種方法可以通過指定對象的位置來控制它:

If you want to specify the appearance to be applied only in some view controllers there is also a method in the docs to control that by specifying where your objects are located:

[[UIBarButtonItem appearanceWhenContainedIn:
    [ABPeoplePickerNavigationController class], nil] setTintColor:myNavBarColor];

另外值得一提的是,如果您有單個自定義實例,與您的外觀設(shè)置不同,這些實例將不受外觀代理的影響.

Also worth to mention is, if you have single customized instances, differing from your appearance settings, theses instances will not be effected by the appearance proxy.

一些問題:

a) 我如何知道類的哪些屬性與外觀屬性一起使用? 例如因為 UITableView 符合 UIAppearance 協(xié)議,所以我想我可以做類似的事情

a) How do I know which properties of a class work with the appearance property? For e.g. since UITableView conforms to the UIAppearance protocol I was thinking I could do something like

[[UITableView appearance] setBackgroundColor:mytableViewColor];

來操縱我所有表格視圖的背景顏色,但我不能!

to manipulate the background color of all my table views, but I can't!

b) 是否有所有可使用外觀屬性操作的類的列表?

c) 在什么時候調(diào)用外觀自定義? 我希望在運行時對外觀屬性進行更改,但不幸的是,這些更改沒有發(fā)生.

c) At what point is the appearance customization being called? I was hoping to make changes threw the appearance property at runtime, but unfortunately the changes aren't taking place.

推薦答案

a) 我如何知道某個類的哪些實例與外觀屬性一起使用?例如因為 UITableView 符合 UIAppearance 協(xié)議,所以我想我可以做類似的事情

a) How do I know which instances of a class work with the appearance property? For e.g. since UITableView conforms to the UIAppearance protocol I was thinking I could do something like

您查看類的標(biāo)題(以及所有超類的標(biāo)題).UI_APPEARANCE_SELECTOR 旁邊的任何方法都支持與 UIAppearance 代理一起使用.

You look in the header of the class (and the headers of all the superclasses). Any method that has UI_APPEARANCE_SELECTOR next to it is supported for use with the UIAppearance proxy.

[[UITableView appearance] setBackgroundColor:mytableViewColor];

backgroundColor 屬性未使用 UIView.h 中的 UI_APPEARANCE_SELECTOR 修飾.因此,它在技術(shù)上不支持與外觀代理一起使用.它可能會起作用,但(鑒于缺乏方法修飾)不能保證.

The backgroundColor property is not decorated with UI_APPEARANCE_SELECTOR in UIView.h. Thus it is not technically supported for use with the appearance proxy. It will probably work, but (given the lack of method decoration) isn't guaranteed to.

來自UIAppearance 協(xié)議參考:

要支持外觀定制,類必須符合UIAppearanceContainer協(xié)議,相關(guān)訪問器方法必須用UI_APPEARANCE_SELECTOR標(biāo)記.

To support appearance customization, a class must conform to the UIAppearanceContainer protocol and relevant accessor methods must be marked with UI_APPEARANCE_SELECTOR.

(注意相關(guān)的訪問器方法必須標(biāo)記..."[強調(diào)添加])

(note "and relevant accessor methods must be marked..." [emphasis added])

b) 是否有所有可使用外觀屬性進行操作的屬性的列表?

b) Is there a list of all properties that are manipulatable with the appearance property?

是否有一個頁面顯示每個使用外觀代理的設(shè)置器?我不知道,也沒有辦法在運行時構(gòu)建列表.

Is there a single page showing every setter that works with the appearance proxy? I don't know of one, nor is there a way to build the list at runtime.

c) 在什么時候調(diào)用外觀定制?我希望在運行時對外觀屬性進行更改,但不幸的是沒有發(fā)生更改.

c) At what point is the appearance customization being called? I was hoping to make changes threw the appearance property at runtime, but unfortunately the changes aren't taking place.

您可以在執(zhí)行期間的任何時候使用外觀代理.直到下次調(diào)用這些視圖的 -layoutSubviews 方法時,這些更改才會應(yīng)用于受影響的視圖.

You can use the appearance proxy at any point during execution. The changes won't be applied to the affected views until the next time those views have their -layoutSubviews method invoked.

這篇關(guān)于iOS 5:對 UIAppearance 感到好奇的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應(yīng)用程序以找出罕見 UI 錯誤的原因?)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態(tài)和動態(tài)單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
Having trouble creating UIImage from CIImage in iOS5(在 iOS5 中從 CIImage 創(chuàng)建 UIImage 時遇到問題)
Get list of all photo albums and thumbnails for each album(獲取所有相冊的列表和每個相冊的縮略圖)
Can anybody help me in recording iPhone output sound through Audio Unit(誰能幫我通過音頻單元錄制 iPhone 輸出的聲音)
主站蜘蛛池模板: 亚洲欧美中文日韩在线 | 狠狠操狠狠干 | 国产精品日韩在线观看一区二区 | 免费成人av网站 | 日韩激情一区 | 国产精品一区二区久久 | 国产精品91网站 | 五月天天色 | 日本激情一区二区 | 久久久久一区二区 | 国产精品一区二区三区在线 | 91看片网 | 亚洲最大av网站 | 视频1区| 日韩久久久久久 | 免费在线观看黄视频 | 色视频免费 | 国产精品美女 | 国产特级毛片 | 亚洲人成人一区二区在线观看 | 日日久 | 色天堂视频 | 国产免费观看久久黄av片涩av | 久久久国产一区二区三区四区小说 | 国产精品夜夜夜一区二区三区尤 | 久久精品国产一区老色匹 | 男女视频91 | 青青艹在线视频 | 亚洲欧美日韩电影 | 亚洲色图图片 | 国产成人99久久亚洲综合精品 | www国产成人免费观看视频,深夜成人网 | 狠狠色网| 国产97在线看| 99re在线免费视频 | 国产91在线播放精品91 | 国产精品毛片无码 | 亚洲国产欧美在线 | 亚洲午夜视频在线观看 | 99精品99| 日韩欧美中文字幕在线观看 |