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

iOS 5:對 UIAppearance 感到好奇

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

問題描述

限時送ChatGPT賬號..

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

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:

關于UIAppearance:

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

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]; 

這將設置應用程序中所有導航欄的背景圖像.使用 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.

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

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];

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

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 協議,所以我想我可以做類似的事情

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) 在什么時候調用外觀自定義? 我希望在運行時對外觀屬性進行更改,但不幸的是,這些更改沒有發生.

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 協議,所以我想我可以做類似的事情

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

您查看類的標題(以及所有超類的標題).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 修飾.因此,它在技術上不支持與外觀代理一起使用.它可能會起作用,但(鑒于缺乏方法修飾)不能保證.

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 協議參考:

要支持外觀定制,類必須符合UIAppearanceContainer協議,相關訪問器方法必須用UI_APPEARANCE_SELECTOR標記.

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

(注意相關的訪問器方法必須標記..."[強調添加])

(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?

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

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) 在什么時候調用外觀定制?我希望在運行時對外觀屬性進行更改,但不幸的是沒有發生更改.

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.

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

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.

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

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

相關文檔推薦

KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
Having trouble creating UIImage from CIImage in iOS5(在 iOS5 中從 CIImage 創建 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 輸出的聲音)
主站蜘蛛池模板: 日韩中文字幕一区二区 | 91成人精品视频 | 午夜免费网站 | 国产欧美精品区一区二区三区 | 91亚洲国产成人久久精品网站 | 成人中文网 | 国产欧美久久精品 | 欧美综合久久 | 一区视频在线播放 | 国产午夜精品福利 | 七七婷婷婷婷精品国产 | 亚洲精品视频在线看 | 91久久久久久久久 | 日韩在线观看网站 | 国产一区欧美一区 | 欧美片网站免费 | 日本xx视频免费观看 | 久久一级 | 久久伊人操 | 精品一区二区av | 欧美精品一区二区三区四区 在线 | 天天夜天天操 | 国产探花在线精品一区二区 | 国产欧美一区二区三区国产幕精品 | 国产一区二区三区免费观看视频 | 99热国产免费 | 毛片区| 中文字幕亚洲欧美 | 久久久久国产精品 | 日韩黄a | 免费成人高清在线视频 | 欧美综合一区 | 日韩精品一区二区三区免费视频 | 成人在线视频免费观看 | 一级毛片免费完整视频 | 黄色精品 | 久草热播 | 亚洲不卡在线观看 | 黄色一级片视频 | 欧美特级黄色 | 在线欧美a |