<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Manipulating UIColors</title>
	<atom:link href="http://www.cocoanetics.com/2009/10/manipulating-uicolors/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cocoanetics.com/2009/10/manipulating-uicolors/</link>
	<description>Our DNA is written in Objective-C</description>
	<lastBuildDate>Mon, 14 May 2012 19:43:35 +0100</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: mariomariani.myopenid.com/</title>
		<link>http://www.cocoanetics.com/2009/10/manipulating-uicolors/#comment-1427</link>
		<dc:creator>mariomariani.myopenid.com/</dc:creator>
		<pubDate>Fri, 12 Mar 2010 16:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=1352#comment-1427</guid>
		<description>Good stuff, but... Why not?

- (UIColor *)colorByDarkeningColorBy:(CGFloat)alpha
{
      CGColorRef oldColor = CGColorCreateCopyWithAlpha([self CGColor], alpha);
      UIColor *newColor = [UIColor colorWithCGColor:oldColor];
      CGColorRelease(oldColor);

      return newColor;
}</description>
		<content:encoded><![CDATA[<p>Good stuff, but&#8230; Why not?</p>
<p>- (UIColor *)colorByDarkeningColorBy:(CGFloat)alpha<br />
{<br />
      CGColorRef oldColor = CGColorCreateCopyWithAlpha([self CGColor], alpha);<br />
      UIColor *newColor = [UIColor colorWithCGColor:oldColor];<br />
      CGColorRelease(oldColor);</p>
<p>      return newColor;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rudifa</title>
		<link>http://www.cocoanetics.com/2009/10/manipulating-uicolors/#comment-1426</link>
		<dc:creator>rudifa</dc:creator>
		<pubDate>Tue, 03 Nov 2009 16:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=1352#comment-1426</guid>
		<description>Manipulating UIColor : just what I was looking for. Thank you!

I made a generalization of your darkening method, here it is for anyone interested :


&lt;code&gt;

- (UIColor *)colorByDarkeningColorBy:(CGFloat)factor0to1
{
	// oldComponents is the array INSIDE the original color
	// changing these changes the original, so we copy it
	CGFloat *oldComponents = (CGFloat *)CGColorGetComponents([self CGColor]);
	CGFloat newComponents[4];

	int numComponents = CGColorGetNumberOfComponents([self CGColor]);

	switch (numComponents)
	{
		case 2:
		{
			//grayscale
			newComponents[0] = oldComponents[0]*factor0to1;
			newComponents[1] = oldComponents[0]*factor0to1;
			newComponents[2] = oldComponents[0]*factor0to1;
			newComponents[3] = oldComponents[1];
			break;
		}
		case 4:
		{
			//RGBA
			newComponents[0] = oldComponents[0]*factor0to1;
			newComponents[1] = oldComponents[1]*factor0to1;
			newComponents[2] = oldComponents[2]*factor0to1;
			newComponents[3] = oldComponents[3];
			break;
		}
	}

	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
	CGColorRef newColor = CGColorCreate(colorSpace, newComponents);
	CGColorSpaceRelease(colorSpace);

	UIColor *retColor = [UIColor colorWithCGColor:newColor];
	CGColorRelease(newColor);

	return retColor;
}

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Manipulating UIColor : just what I was looking for. Thank you!</p>
<p>I made a generalization of your darkening method, here it is for anyone interested :</p>
<p><code></p>
<p>- (UIColor *)colorByDarkeningColorBy:(CGFloat)factor0to1<br />
{<br />
	// oldComponents is the array INSIDE the original color<br />
	// changing these changes the original, so we copy it<br />
	CGFloat *oldComponents = (CGFloat *)CGColorGetComponents([self CGColor]);<br />
	CGFloat newComponents[4];</p>
<p>	int numComponents = CGColorGetNumberOfComponents([self CGColor]);</p>
<p>	switch (numComponents)<br />
	{<br />
		case 2:<br />
		{<br />
			//grayscale<br />
			newComponents[0] = oldComponents[0]*factor0to1;<br />
			newComponents[1] = oldComponents[0]*factor0to1;<br />
			newComponents[2] = oldComponents[0]*factor0to1;<br />
			newComponents[3] = oldComponents[1];<br />
			break;<br />
		}<br />
		case 4:<br />
		{<br />
			//RGBA<br />
			newComponents[0] = oldComponents[0]*factor0to1;<br />
			newComponents[1] = oldComponents[1]*factor0to1;<br />
			newComponents[2] = oldComponents[2]*factor0to1;<br />
			newComponents[3] = oldComponents[3];<br />
			break;<br />
		}<br />
	}</p>
<p>	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();<br />
	CGColorRef newColor = CGColorCreate(colorSpace, newComponents);<br />
	CGColorSpaceRelease(colorSpace);</p>
<p>	UIColor *retColor = [UIColor colorWithCGColor:newColor];<br />
	CGColorRelease(newColor);</p>
<p>	return retColor;<br />
}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wuf810</title>
		<link>http://www.cocoanetics.com/2009/10/manipulating-uicolors/#comment-1425</link>
		<dc:creator>wuf810</dc:creator>
		<pubDate>Tue, 06 Oct 2009 11:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=1352#comment-1425</guid>
		<description>Brilliantly useful.

Just last night I was looking up the native values of the default colors (like redColor etc.) just so I could set an lapha by re-creating them using colorWithRed....

Thanks, M.</description>
		<content:encoded><![CDATA[<p>Brilliantly useful.</p>
<p>Just last night I was looking up the native values of the default colors (like redColor etc.) just so I could set an lapha by re-creating them using colorWithRed&#8230;.</p>
<p>Thanks, M.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

