緒論:
可能我們會遇到給TabBar添加圖片的時候,各種問題汗洒,各種顯示议纯,瞬間有點凌亂的趕腳,今天來解釋UIImageRenderingMode溢谤。
UIImageRenderingMode
在IOS7中增加創(chuàng)建UITabBarItem的方法的同時新增了 UIImageRenderingMode屬性瞻凤。
typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
UIImageRenderingModeAutomatic, // Use the default rendering mode for the context where the image is used
UIImageRenderingModeAlwaysOriginal, // Always draw the original image, without treating it as a template
UIImageRenderingModeAlwaysTemplate, // Always draw the image as a template image, ignoring its color information } NS_ENUM_AVAILABLE_IOS(7_0);
}
- 1.UIImageRenderingModeAutomatic // 根據(jù)圖片的使用環(huán)境和所處的繪圖上下文自動調(diào)整渲染模式憨攒。
- 2.UIImageRenderingModeAlwaysOriginal // 始終繪制圖片原始狀態(tài),不使用Tint Color鲫构。
- 3.UIImageRenderingModeAlwaysTemplate // 始終根據(jù)Tint Color繪制圖片浓恶,忽略圖片的顏色信息。
注: UIImageRenderingMode屬性的默認值是UIImageRenderingModeAutomatic结笨,即UIImage是否使用Tint Color取決于它顯示的位置。其他情況可以看下面的圖例