Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
UIColor: Difference between revisions - iPhone Development Wiki

UIColor: Difference between revisions

From iPhone Development Wiki
m (Thai.)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{occlass|library=UIKit.framework}}
<small>'''Languages: English &bull; [[UIColor/fr|français]]''' &bull; '''[[UIColor/th|ไทย]]'''</small>


[[UIColor]] is a class representing a solid color or a pattern, similar to brushes in Windows GDI.
[[UIColor]] is a class representing a solid color or a pattern, similar to brushes in Windows GDI.


== Predefined colors ==
== Predefined colors ==
UIColor defines a list of commonly accessed colors. They can be received using <tt>+[UIColor </tt>''someColor''<tt>]</tt>, as listed below:
UIColor defines a list of commonly accessed colors. They can be received using {{ObjcCall|UIColor|''someColor''|ClassMethod=1}}, as listed below:


=== Documented solid colors ===
=== Documented solid colors ===
{| class="wikitable" style="text-align: center; width: 100%;"
{| class="wikitable" style="text-align: left; width: 100%;"
|- style="height: 50px;"
|- style="height: 50px;"
| style="background-color: black;" width="5%" |  
| style="background-color: black;" width="5%" |  
Line 53: Line 53:
=== Undocumented solid colors ===
=== Undocumented solid colors ===


{| class="wikitable" style="text-align: center; width: 100%;"
{| class="wikitable" style="text-align: left; width: 100%;"
|- style="height: 50px;"
|- style="height: 50px;"
| style="background-color: #A8ABAD;" width="5%" |  
| style="background-color: #ABABAB;" width="5%" |  
| width="20%" | <tt>tableSeparatorDarkColor</tt><br />0.66, 0.67, 0.68
| width="20%" | <tt>tableSeparatorDarkColor</tt><br />0.67, 0.67, 0.67
| style="background-color: #E0E0E0;" width="5%" |  
| style="background-color: #E0E0E0;" width="5%" |  
| width="20%" | <tt>tableSeparatorLightColor</tt><br />0.88, 0.88, 0.88
| width="20%" | <tt>tableSeparatorLightColor</tt><br />0.88, 0.88, 0.88
Line 87: Line 87:
| style="background-color: #4d576b;" |
| style="background-color: #4d576b;" |
| <tt>infoTextOverPinStripeTextColor</tt><br />0.30, 0.34, 0.42
| <tt>infoTextOverPinStripeTextColor</tt><br />0.30, 0.34, 0.42
| style="background-color: #385487;" |
| <tt>tableCellValue1BlueColor</tt><br />0.22, 0.33, 0.53
| style="background-color: #526691;" |
| <tt>tableCellValue2BlueColor</tt><br />0.32, 0.40, 0.57
| style="background-color: black;" |
| <tt>tableGroupedSeparatorLightColor</tt><br />0.00, 0.00, 0.00 [18% alpha]
|- style="height: 50px;"
| style="background-color: white;" |
| <tt>tableCellPlainBackgroundColor</tt><br />1.00, 1.00, 1.00
| style="padding: 0;" | <table width="100%" cellspacing="0"><tr><td style="background-color: #f7f7f7; height:21px; border-width: 0;"> </td></tr><tr><td style="background-color: white; height:21px; border-width: 0;"> </td></tr></table>
| <tt>tableCellGroupedBackgroundColor</tt><br /><span style="font-size:0.5em;">0.97, 0.97, 0.97 (iPad) / 1.00, 1.00, 1.00 (iPhone)</span>
| style="background-color: #ffffe8;" |
| <tt>tableShadowColor</tt><br />1.00, 1.00, 0.91
| style="background-color: black;" |
| <tt>tableGroupedTopShadowColor</tt><br />0.00, 0.00, 0.00 [8% alpha]
|- style="height: 50px;"
| style="background-color: #0054a6;" |
| <tt>selectionTintColor</tt><br />0.00, 0.33, 0.65 [20% alpha]
| style="padding: 0;" | <table width="100%" cellspacing="0"><tr><td style="background-color: #426bf2; height:21px; border-width: 0;"> </td></tr><tr><td style="background-color: #684f45; height:21px; border-width: 0;"> </td></tr></table>
| <tt>textCaretColor</tt><br /><span style="font-size:0.5em;">0.26, 0.42, 0.95 / 0.41, 0.31, 0.27 (MobileNotes)</span>
| style="background-color: #426bf2;" |
| <tt>selectionCaretColor</tt><br />0.26, 0.42, 0.95
| style="background-color: #70a8fc;" |
| <tt>selectionHighlightColor</tt><br />0.44, 0.66, 0.99 [18% alpha]
|- style="height: 50px;"
| style="background-color: #058cf5;" |
| <tt>tableSelectionGradientStartColor</tt><br />0.02, 0.55, 0.96
| style="background-color: #0a5ee8;" |
| <tt>tableSelectionGradientEndColor</tt><br />0.04, 0.37, 0.91
|}
|}


Line 93: Line 125:
{| class="wikitable"  
{| class="wikitable"  
|- style="height: 52px;"
|- style="height: 52px;"
| rowspan="3" style="padding:0px;" | [[Image:UIColorPatterns.png]]
| rowspan="6" style="padding:0px;" | [[Image:UIColorPatterns.png]]
| <tt>groupTableViewBackgroundColor</tt>
| <tt>pinStripeColor</tt> || UIPinStripe.png
|- style="height: 51px;"
| <tt>viewFlipsideBackgroundColor</tt><br />(Public) || UIStockImageWidgetBacksideBackground.png
|- style="height: 51px;"
| <tt>underPageBackgroundColor</tt> || UIStockImageUnderPageBackground.png
|- style="height: 51px;"
| <tt>noContentLightGradientBackgroundColor</tt> || UIStockImageNoContentLightGradientBackgroundColor.png
|- style="height: 51px;"
|- style="height: 51px;"
| <tt>viewFlipsideBackgroundColor</tt>
| <tt>noContentDarkGradientBackgroundColor</tt> || UIStockImageNoContentDarkGradientBackgroundColor.png
|- style="height: 51px;"
|- style="height: 51px;"
| <tt>underPageBackgroundColor</tt><br />(Private)
| <tt>scrollViewTexturedBackgroundColor</tt><br />(Public) || UIStockImageScrollViewTexturedBackgroundColor.png
|}
|}
Note: the public colors {{ObjcCall|UIColor|scrollViewTexturedBackgroundColor|ClassMethod=1}} and {{ObjcCall|UIColor|groupTableViewBackgroundColor|ClassMethod=1}} return <tt>pinStripeColor</tt> on iPhone and <tt>clearColor</tt> on iPad.
==== Custom Patterns ====
If the default textures or colors don't suit, and you don't want a solid color, an image file can be loaded to behave similar to the Patterns above via {{ObjcCall|UIColor|colorWithPatternImage:|ClassMethod=1}}.
If an image is too small to fit, the OS will tile the image over the screen, and this technique can be used to make backgrounds from small image files. If a image is too large, it continues off the screen.


== CSS colors ==
== CSS colors ==
{{Function_signature
{{Function_signature
|signature=-(NSString*)styleString
|signature=-(NSString*)styleString
|firmware=2.0 – 3.1
|firmware=2.0 –
}}
}}


Line 112: Line 158:
* Official documentation: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIColor_Class/Reference/Reference.html
* Official documentation: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIColor_Class/Reference/Reference.html
* Extra header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIColor2.h
* Extra header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIColor2.h
{{occlass|library=UIKit.framework|navbox=on}}

Latest revision as of 04:07, 18 May 2014

Languages: English • françaisไทย

UIColor is a class representing a solid color or a pattern, similar to brushes in Windows GDI.

Predefined colors

UIColor defines a list of commonly accessed colors. They can be received using +[UIColor someColor], as listed below:

Documented solid colors

blackColor
0.000
darkGrayColor
0.333
lightGrayColor
0.667
whiteColor
1.000
grayColor
0.500
redColor
1.00, 0.00, 0.00
greenColor
0.00, 1.00, 0.00
blueColor
0.00, 0.00, 1.00
cyanColor
0.00, 1.00, 1.00
yellowColor
1.00, 1.00, 0.00
magentaColor
1.00, 0.00, 1.00
orangeColor
1.00, 0.50, 0.00
purpleColor
0.50, 0.00, 0.50
brownColor
0.60, 0.40, 0.20
clearColor
0.000 [0% alpha]
lightTextColor
1.000 [60% alpha]
darkTextColor
0.000

Undocumented solid colors

tableSeparatorDarkColor
0.67, 0.67, 0.67
tableSeparatorLightColor
0.88, 0.88, 0.88
tableBackgroundColor
1.00, 1.00, 1.00
tableSelectionColor
0.16, 0.43, 0.83
sectionListBorderColor
0.52, 0.56, 0.58 [60% alpha]
sectionHeaderBackgroundColor
0.90, 0.93, 0.99 [80% alpha]
sectionHeaderOpaqueBackgroundColor
0.92, 0.94, 0.99
sectionHeaderBorderColor
0.85, 0.87, 0.91
tableCellBlueTextColor
0.22, 0.33, 0.53
tableCellGrayTextColor
0.50, 0.50, 0.50
textFieldAtomBlueColor
0.16, 0.34, 1.00
textFieldAtomPurpleColor
0.41, 0.00, 0.74
infoTextOverPinStripeTextColor
0.30, 0.34, 0.42
tableCellValue1BlueColor
0.22, 0.33, 0.53
tableCellValue2BlueColor
0.32, 0.40, 0.57
tableGroupedSeparatorLightColor
0.00, 0.00, 0.00 [18% alpha]
tableCellPlainBackgroundColor
1.00, 1.00, 1.00
tableCellGroupedBackgroundColor
0.97, 0.97, 0.97 (iPad) / 1.00, 1.00, 1.00 (iPhone)
tableShadowColor
1.00, 1.00, 0.91
tableGroupedTopShadowColor
0.00, 0.00, 0.00 [8% alpha]
selectionTintColor
0.00, 0.33, 0.65 [20% alpha]
textCaretColor
0.26, 0.42, 0.95 / 0.41, 0.31, 0.27 (MobileNotes)
selectionCaretColor
0.26, 0.42, 0.95
selectionHighlightColor
0.44, 0.66, 0.99 [18% alpha]
tableSelectionGradientStartColor
0.02, 0.55, 0.96
tableSelectionGradientEndColor
0.04, 0.37, 0.91

Patterns

UIColorPatterns.png pinStripeColor UIPinStripe.png
viewFlipsideBackgroundColor
(Public)
UIStockImageWidgetBacksideBackground.png
underPageBackgroundColor UIStockImageUnderPageBackground.png
noContentLightGradientBackgroundColor UIStockImageNoContentLightGradientBackgroundColor.png
noContentDarkGradientBackgroundColor UIStockImageNoContentDarkGradientBackgroundColor.png
scrollViewTexturedBackgroundColor
(Public)
UIStockImageScrollViewTexturedBackgroundColor.png

Note: the public colors +[UIColor scrollViewTexturedBackgroundColor] and +[UIColor groupTableViewBackgroundColor] return pinStripeColor on iPhone and clearColor on iPad.

Custom Patterns

If the default textures or colors don't suit, and you don't want a solid color, an image file can be loaded to behave similar to the Patterns above via +[UIColor colorWithPatternImage:].

If an image is too small to fit, the OS will tile the image over the screen, and this technique can be used to make backgrounds from small image files. If a image is too large, it continues off the screen.

CSS colors

Signature -(NSString*)styleString
Available in 2.0 –

UIColors can be converted to CSS colors by the -styleString method. For example, [[UIColor lightTextColor] styleString] gives @"rgba(255,255,255,153)".

References