<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Notes of a Developer &#187; Apple</title>
	<atom:link href="http://www.developers-life.com/category/apple/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developers-life.com</link>
	<description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:49:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ANSI escape sequences for coloring</title>
		<link>http://www.developers-life.com/ansi-escape-sequences-for-coloring.html</link>
		<comments>http://www.developers-life.com/ansi-escape-sequences-for-coloring.html#comments</comments>
		<pubDate>Thu, 02 Feb 2012 11:06:07 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[ANSI]]></category>
		<category><![CDATA[GeekTool]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1434</guid>
		<description><![CDATA[More about ANSI escape code I modify my twitter script from previous post and now timeline looks like this:]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-12.58.01-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-12.58.01-PM-234x300.png" alt="" title="Screen Shot 2012-02-02 at 12.58.01 PM" width="234" height="300" class="alignnone size-medium wp-image-1435" /></a></p>
<p>More about <a href="http://en.wikipedia.org/wiki/ANSI_escape_code" target="_blank">ANSI escape code</a></p>
<p>I modify my twitter script from previous post and now timeline looks like this:<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-1.04.46-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-1.04.46-PM-188x300.png" alt="" title="twitter timeline on desktop mac os x" width="188" height="300" class="alignnone size-medium wp-image-1436" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/ansi-escape-sequences-for-coloring.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Modified Neon(author zb3k) Bowtie theme</title>
		<link>http://www.developers-life.com/modified-neonby-zb3k-bowtie-theme.html</link>
		<comments>http://www.developers-life.com/modified-neonby-zb3k-bowtie-theme.html#comments</comments>
		<pubDate>Thu, 02 Feb 2012 09:04:47 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[album art]]></category>
		<category><![CDATA[Bowtie]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1429</guid>
		<description><![CDATA[If album does not has artwork: Download theme]]></description>
			<content:encoded><![CDATA[<p>If album does not has artwork:<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-11.02.47-AM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-11.02.47-AM.png" alt="" title="Screen Shot 2012-02-02 at 11.02.47 AM" width="275" height="140" class="alignnone size-full wp-image-1430" /></a></p>
<p><a href="http://goo.gl/Wtno6" target="_blank">Download theme</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/modified-neonby-zb3k-bowtie-theme.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get twitter timeline in Command line (for GeekTool)</title>
		<link>http://www.developers-life.com/how-to-get-twitter-timeline-in-command-line-for-geektool.html</link>
		<comments>http://www.developers-life.com/how-to-get-twitter-timeline-in-command-line-for-geektool.html#comments</comments>
		<pubDate>Tue, 31 Jan 2012 21:32:55 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[GeekTool]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1421</guid>
		<description><![CDATA[Install next gem yajl-ruby, twitter, htmlentities 1sudo gem install yajl-ruby twitter htmlentities create app on twitter developer portal and copy keys 12345678910111213141516171819202122#!/usr/bin/ruby # Copyright Vladimir Boychentsov, 2012 # site http://www.developers-life.com/ # Released under BSD require 'rubygems' require 'twitter' require 'htmlentities' Twitter.configure do &#124;config&#124; &#160; config.consumer_key = &#34;Consumer key&#34; &#160; config.consumer_secret = &#34;Consumer secret&#34; &#160; config.oauth_token [...]]]></description>
			<content:encoded><![CDATA[<p>Install next gem yajl-ruby, twitter, htmlentities</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> yajl-ruby twitter htmlentities</div></td></tr></tbody></table></div>
<p>create app on <a href="https://dev.twitter.com/" target="_blank">twitter developer portal</a> and copy keys</p>
<div class="codecolorer-container ruby geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span><br />
<span style="color:#008000; font-style:italic;"># Copyright Vladimir Boychentsov, 2012</span><br />
<span style="color:#008000; font-style:italic;"># site http://www.developers-life.com/</span><br />
<span style="color:#008000; font-style:italic;"># Released under BSD</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'twitter'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'htmlentities'</span><br />
<br />
Twitter.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; config.<span style="color:#9900CC;">consumer_key</span> = <span style="color:#996600;">&quot;Consumer key&quot;</span><br />
&nbsp; config.<span style="color:#9900CC;">consumer_secret</span> = <span style="color:#996600;">&quot;Consumer secret&quot;</span><br />
&nbsp; config.<span style="color:#9900CC;">oauth_token</span> = <span style="color:#996600;">&quot;Access token&quot;</span><br />
&nbsp; config.<span style="color:#9900CC;">oauth_token_secret</span> = <span style="color:#996600;">&quot;Access token secret&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
decoder = HTMLEntities.<span style="color:#9900CC;">new</span><br />
<br />
tweets = Twitter.<span style="color:#9900CC;">home_timeline</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">for</span> tweet <span style="color:#9966CC; font-weight:bold;">in</span> tweets<br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">printf</span> <span style="color:#996600;">&quot;%s: %s&quot;</span>,tweet.<span style="color:#9900CC;">user</span>.<span style="color:#9900CC;">screen_name</span>,decoder.<span style="color:#9900CC;">decode</span><span style="color:#006600; font-weight:bold;">&#40;</span>tweet.<span style="color:#9900CC;">text</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span><span style="color:#000099;">\n</span>&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>Or use this code for GeekTool like this<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-1.04.46-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-02-at-1.04.46-PM-188x300.png" alt="" title="twitter timeline on desktop mac os x" width="188" height="300" class="alignnone size-medium wp-image-1436" /></a></p>
<p>P.S.: in next post I will write about coloring text</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/how-to-get-twitter-timeline-in-command-line-for-geektool.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create movie from array of images</title>
		<link>http://www.developers-life.com/create-movie-from-array-of-images.html</link>
		<comments>http://www.developers-life.com/create-movie-from-array-of-images.html#comments</comments>
		<pubDate>Mon, 30 Jan 2012 21:22:59 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[AVAssetWriter]]></category>
		<category><![CDATA[AVAssetWriterInput]]></category>
		<category><![CDATA[AVCaptureDeviceInput]]></category>
		<category><![CDATA[AVCaptureVideoDataOutput]]></category>
		<category><![CDATA[AVFoundation]]></category>
		<category><![CDATA[QuartzCore]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1407</guid>
		<description><![CDATA[Create movie from images seq. First part of method, initialize 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950- &#40;void&#41; writeImagesAsMovie:&#40;NSArray *&#41;array toPath:&#40;NSString*&#41;path &#123; &#160; &#160; NSString *documents = &#91;NSSearchPathForDirectoriesInDomains &#40;NSDocumentDirectory, NSUserDomainMask, YES&#41; objectAtIndex: 0&#93;; &#160; &#160; documents = &#91;documents stringByAppendingPathComponent:currentWorkspace&#93;; &#160; &#160; &#160; &#160; //NSLog(path); &#160; &#160; NSString *filename = &#91;documents stringByAppendingPathComponent:&#91;array objectAtIndex:0&#93;&#93;; &#160; &#160; UIImage *first = &#91;UIImage imageWithContentsOfFile:filename&#93;; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Create movie from images seq.</p>
<p>First part of method, initialize</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> writeImagesAsMovie<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>array toPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>documents <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSSearchPathForDirectoriesInDomains <span style="color: #002200;">&#40;</span>NSDocumentDirectory, NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span> objectAtIndex<span style="color: #002200;">:</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; documents <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>documents stringByAppendingPathComponent<span style="color: #002200;">:</span>currentWorkspace<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">//NSLog(path);</span><br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>filename <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>documents stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>array objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; UIImage <span style="color: #002200;">*</span>first <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span>filename<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGSize frameSize <span style="color: #002200;">=</span> first.size;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"><span style="color: #400080;">NSError</span></a> <span style="color: #002200;">*</span>error <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;<br />
&nbsp; &nbsp; AVAssetWriter <span style="color: #002200;">*</span>videoWriter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>AVAssetWriter alloc<span style="color: #002200;">&#93;</span> initWithURL<span style="color: #002200;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> fileURLWithPath<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> fileType<span style="color: #002200;">:</span>AVFileTypeQuickTimeMovie<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>error<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;error creating AssetWriter: %@&quot;</span>,<span style="color: #002200;">&#91;</span>error description<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>videoSettings <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AVVideoCodecH264, AVVideoCodecKey,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithInt<span style="color: #002200;">:</span>frameSize.width<span style="color: #002200;">&#93;</span>, AVVideoWidthKey,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithInt<span style="color: #002200;">:</span>frameSize.height<span style="color: #002200;">&#93;</span>, AVVideoHeightKey,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; AVAssetWriterInput<span style="color: #002200;">*</span> writerInput <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>AVAssetWriterInput<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assetWriterInputWithMediaType<span style="color: #002200;">:</span>AVMediaTypeVideo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputSettings<span style="color: #002200;">:</span>videoSettings<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> <span style="color: #002200;">*</span>attributes <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>attributes setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithUnsignedInt<span style="color: #002200;">:</span>kCVPixelFormatType_32ARGB<span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>kCVPixelBufferPixelFormatTypeKey<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>attributes setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithUnsignedInt<span style="color: #002200;">:</span>frameSize.width<span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>kCVPixelBufferWidthKey<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>attributes setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithUnsignedInt<span style="color: #002200;">:</span>frameSize.height<span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>kCVPixelBufferHeightKey<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; AVAssetWriterInputPixelBufferAdaptor <span style="color: #002200;">*</span>adaptor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>AVAssetWriterInputPixelBufferAdaptor<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;assetWriterInputPixelBufferAdaptorWithAssetWriterInput<span style="color: #002200;">:</span>writerInput<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sourcePixelBufferAttributes<span style="color: #002200;">:</span>attributes<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>videoWriter addInput<span style="color: #002200;">:</span>writerInput<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// fixes all errors</span><br />
&nbsp; &nbsp; writerInput.expectsMediaDataInRealTime <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">//Start a session:</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">BOOL</span> start <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>videoWriter startWriting<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Session started? %d&quot;</span>, start<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>videoWriter startSessionAtSourceTime<span style="color: #002200;">:</span>kCMTimeZero<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p><span id="more-1407"></span></p>
<p>Second part, writing</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; CVPixelBufferRef buffer <span style="color: #002200;">=</span> <span style="color: #a61390;">NULL</span>;<br />
&nbsp; &nbsp; buffer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self pixelBufferFromCGImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>first CGImage<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">BOOL</span> result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>adaptor appendPixelBuffer<span style="color: #002200;">:</span>buffer withPresentationTime<span style="color: #002200;">:</span>kCMTimeZero<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>result <span style="color: #002200;">==</span> <span style="color: #a61390;">NO</span><span style="color: #002200;">&#41;</span> <span style="color: #11740a; font-style: italic;">//failes on 3GS, but works on iphone 4</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;failed to append buffer&quot;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>buffer<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CVBufferRelease<span style="color: #002200;">&#40;</span>buffer<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/"><span style="color: #400080;">NSThread</span></a> sleepForTimeInterval<span style="color: #002200;">:</span><span style="color: #2400d9;">0.05</span><span style="color: #002200;">&#93;</span>;<br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">int</span> reverseSort <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>newArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>array sortedArrayUsingFunction<span style="color: #002200;">:</span>sort context<span style="color: #002200;">:&amp;</span>reverseSort<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; delta <span style="color: #002200;">=</span> <span style="color: #2400d9;">1.0</span><span style="color: #002200;">/</span><span style="color: #002200;">&#91;</span>newArray count<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">int</span> fps <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>fpsSlider.value;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>filename <span style="color: #a61390;">in</span> newArray<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>adaptor.assetWriterInput.readyForMoreMediaData<span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i<span style="color: #002200;">++</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;inside for loop %d %@ &quot;</span>,i, filename<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CMTime frameTime <span style="color: #002200;">=</span> CMTimeMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">1</span>, fps<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CMTime lastTime<span style="color: #002200;">=</span>CMTimeMake<span style="color: #002200;">&#40;</span>i, fps<span style="color: #002200;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CMTime presentTime<span style="color: #002200;">=</span>CMTimeAdd<span style="color: #002200;">&#40;</span>lastTime, frameTime<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>filePath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>documents stringByAppendingPathComponent<span style="color: #002200;">:</span>filename<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIImage <span style="color: #002200;">*</span>imgFrame <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span>filePath<span style="color: #002200;">&#93;</span> ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buffer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self pixelBufferFromCGImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>imgFrame CGImage<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">BOOL</span> result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>adaptor appendPixelBuffer<span style="color: #002200;">:</span>buffer withPresentationTime<span style="color: #002200;">:</span>presentTime<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>result <span style="color: #002200;">==</span> <span style="color: #a61390;">NO</span><span style="color: #002200;">&#41;</span> <span style="color: #11740a; font-style: italic;">//failes on 3GS, but works on iphone 4</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;failed to append buffer&quot;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;The error is %@&quot;</span>, <span style="color: #002200;">&#91;</span>videoWriter error<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>buffer<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CVBufferRelease<span style="color: #002200;">&#40;</span>buffer<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/"><span style="color: #400080;">NSThread</span></a> sleepForTimeInterval<span style="color: #002200;">:</span><span style="color: #2400d9;">0.05</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;error&quot;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i<span style="color: #002200;">--</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/"><span style="color: #400080;">NSThread</span></a> sleepForTimeInterval<span style="color: #002200;">:</span><span style="color: #2400d9;">0.02</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">//Finish the session:</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>writerInput markAsFinished<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>videoWriter finishWriting<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; CVPixelBufferPoolRelease<span style="color: #002200;">&#40;</span>adaptor.pixelBufferPool<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>videoWriter release<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>writerInput release<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>Convert UIImage to CVPixelBufferRef</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>CVPixelBufferRef<span style="color: #002200;">&#41;</span> pixelBufferFromCGImage<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>CGImageRef<span style="color: #002200;">&#41;</span> image<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span>options <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithBool<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>, kCVPixelBufferCGImageCompatibilityKey,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/"><span style="color: #400080;">NSNumber</span></a> numberWithBool<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>, kCVPixelBufferCGBitmapContextCompatibilityKey,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; CVPixelBufferRef pxbuffer <span style="color: #002200;">=</span> <span style="color: #a61390;">NULL</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CVPixelBufferCreate<span style="color: #002200;">&#40;</span>kCFAllocatorDefault, CGImageGetWidth<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetHeight<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>, kCVPixelFormatType_32ARGB, <span style="color: #002200;">&#40;</span>CFDictionaryRef<span style="color: #002200;">&#41;</span> options, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&amp;</span>pxbuffer<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CVPixelBufferLockBaseAddress<span style="color: #002200;">&#40;</span>pxbuffer, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">void</span> <span style="color: #002200;">*</span>pxdata <span style="color: #002200;">=</span> CVPixelBufferGetBaseAddress<span style="color: #002200;">&#40;</span>pxbuffer<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGColorSpaceRef rgbColorSpace <span style="color: #002200;">=</span> CGColorSpaceCreateDeviceRGB<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; CGContextRef context <span style="color: #002200;">=</span> CGBitmapContextCreate<span style="color: #002200;">&#40;</span>pxdata, CGImageGetWidth<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CGImageGetHeight<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">8</span>, <span style="color: #2400d9;">4</span><span style="color: #002200;">*</span>CGImageGetWidth<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>, rgbColorSpace, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;kCGImageAlphaNoneSkipFirst<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGContextConcatCTM<span style="color: #002200;">&#40;</span>context, CGAffineTransformMakeRotation<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGAffineTransform flipVertical <span style="color: #002200;">=</span> CGAffineTransformMake<span style="color: #002200;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #2400d9;">1</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>, <span style="color: #2400d9;">0</span>, CGImageGetHeight<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; CGContextConcatCTM<span style="color: #002200;">&#40;</span>context, flipVertical<span style="color: #002200;">&#41;</span>; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGAffineTransform flipHorizontal <span style="color: #002200;">=</span> CGAffineTransformMake<span style="color: #002200;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">-</span><span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">0.0</span>, <span style="color: #2400d9;">0.0</span>, <span style="color: #2400d9;">1.0</span>, CGImageGetWidth<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">0.0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGContextConcatCTM<span style="color: #002200;">&#40;</span>context, flipHorizontal<span style="color: #002200;">&#41;</span>; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGContextDrawImage<span style="color: #002200;">&#40;</span>context, CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, CGImageGetWidth<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CGImageGetHeight<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>, image<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; CGColorSpaceRelease<span style="color: #002200;">&#40;</span>rgbColorSpace<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; CGContextRelease<span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CVPixelBufferUnlockBaseAddress<span style="color: #002200;">&#40;</span>pxbuffer, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> pxbuffer;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/create-movie-from-array-of-images.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Masked Shape layer with gradient</title>
		<link>http://www.developers-life.com/masked-shape-layer-with-gradient.html</link>
		<comments>http://www.developers-life.com/masked-shape-layer-with-gradient.html#comments</comments>
		<pubDate>Sat, 28 Jan 2012 14:07:19 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[CABasicAnimation]]></category>
		<category><![CDATA[CAGradientLayer]]></category>
		<category><![CDATA[CALayer]]></category>
		<category><![CDATA[CAShapeLayer]]></category>
		<category><![CDATA[CGMutablePathRef]]></category>
		<category><![CDATA[QuartzCore]]></category>
		<category><![CDATA[UIView]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1396</guid>
		<description><![CDATA[Layer with CGPathRef and animated. And added masked gradient for layer. ViewLayers.h 12345678910111213141516171819202122232425262728293031// // &#160;ViewLayers.h // &#160;layers // // &#160;Created by Volodymyr Boichentsov on 1/28/12. // &#160;Copyright (c) 2012 www.injoit.com. All rights reserved. // #import &#60;UIKit/UIKit.h&#62; #import &#60;QuartzCore/QuartzCore.h&#62; @interface ViewLayers : UIView &#123; &#160; &#160; CGRect firstRect; &#160; &#160; CGRect secondRect; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Layer with CGPathRef and animated. And added masked gradient for layer.</p>
<p>ViewLayers.h</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;ViewLayers.h</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;layers</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Created by Volodymyr Boichentsov on 1/28/12.</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Copyright (c) 2012 www.injoit.com. All rights reserved.</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<br />
<span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span><br />
<span style="color: #6e371a;">#import &lt;QuartzCore/QuartzCore.h&gt;</span><br />
<br />
<span style="color: #a61390;">@interface</span> ViewLayers <span style="color: #002200;">:</span> UIView <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; CGRect firstRect;<br />
&nbsp; &nbsp; CGRect secondRect;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">int</span> cornerRadius;<br />
&nbsp; &nbsp; CGMutablePathRef mainPath;<br />
&nbsp; &nbsp; CGMutablePathRef secondPath;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CAShapeLayer <span style="color: #002200;">*</span>maskLayer;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CAShapeLayer <span style="color: #002200;">*</span>shapeLayer;<br />
&nbsp; &nbsp; CAGradientLayer <span style="color: #002200;">*</span>gradientLayer;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>CGMutablePathRef<span style="color: #002200;">&#41;</span> createPathWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>bubbleRect;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setupLayers;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> animation;<br />
<br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p><span id="more-1396"></span><br />
ViewLayers.m</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;ViewLayers.m</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;layers</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Created by Volodymyr Boichentsov on 1/28/12.</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Copyright (c) 2012 www.injoit.com. All rights reserved.</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<br />
<br />
<span style="color: #6e371a;">#import &quot;ViewLayers.h&quot;</span><br />
<span style="color: #6e371a;">#import &lt;QuartzCore/QuartzCore.h&gt;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> initWithCoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCoder_Class/"><span style="color: #400080;">NSCoder</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>aDecoder <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithCoder<span style="color: #002200;">:</span>aDecoder<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; firstRect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">30</span>, <span style="color: #2400d9;">60</span>, <span style="color: #2400d9;">100</span>, <span style="color: #2400d9;">100</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; secondRect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">20</span>, <span style="color: #2400d9;">20</span>, <span style="color: #2400d9;">280</span>, <span style="color: #2400d9;">420</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cornerRadius <span style="color: #002200;">=</span> <span style="color: #2400d9;">10</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; mainPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self createPathWithFrame<span style="color: #002200;">:</span>firstRect<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; secondPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self createPathWithFrame<span style="color: #002200;">:</span>secondRect<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self setupLayers<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// Initialization code</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>CGMutablePathRef<span style="color: #002200;">&#41;</span> createPathWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>bubbleRect <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; CGMutablePathRef bubblePath <span style="color: #002200;">=</span> CGPathCreateMutable<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGPathMoveToPoint<span style="color: #002200;">&#40;</span>bubblePath, <span style="color: #a61390;">NULL</span>, bubbleRect.origin.x<span style="color: #002200;">+</span>cornerRadius<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , bubbleRect.origin.y<span style="color: #002200;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGPathAddArcToPoint<span style="color: #002200;">&#40;</span>bubblePath, <span style="color: #a61390;">NULL</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bubbleRect.origin.x<span style="color: #002200;">+</span>bubbleRect.size.width, bubbleRect.origin.y,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bubbleRect.origin.x<span style="color: #002200;">+</span>bubbleRect.size.width, bubbleRect.origin.y<span style="color: #002200;">+</span>cornerRadius,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cornerRadius<span style="color: #002200;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; CGPathAddArcToPoint<span style="color: #002200;">&#40;</span>bubblePath, <span style="color: #a61390;">NULL</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x<span style="color: #002200;">+</span>bubbleRect.size.width, bubbleRect.origin.y<span style="color: #002200;">+</span>bubbleRect.size.height,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x<span style="color: #002200;">+</span>bubbleRect.size.width<span style="color: #002200;">-</span>cornerRadius, bubbleRect.origin.y<span style="color: #002200;">+</span>bubbleRect.size.height,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cornerRadius<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGPathAddArcToPoint<span style="color: #002200;">&#40;</span>bubblePath, <span style="color: #a61390;">NULL</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x, bubbleRect.origin.y<span style="color: #002200;">+</span>bubbleRect.size.height,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x, bubbleRect.origin.y<span style="color: #002200;">+</span>bubbleRect.size.height<span style="color: #002200;">-</span>cornerRadius,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cornerRadius<span style="color: #002200;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; CGPathAddArcToPoint<span style="color: #002200;">&#40;</span>bubblePath, <span style="color: #a61390;">NULL</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x, bubbleRect.origin.y,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bubbleRect.origin.x<span style="color: #002200;">+</span>cornerRadius, bubbleRect.origin.y,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cornerRadius<span style="color: #002200;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; CGPathCloseSubpath<span style="color: #002200;">&#40;</span>bubblePath<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> bubblePath;<br />
<span style="color: #002200;">&#125;</span> <br />
<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setupLayers <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; shapeLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CAShapeLayer layer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;shapeLayer.fillColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span>.CGColor; <br />
&nbsp; &nbsp; &nbsp;shapeLayer.fillRule <span style="color: #002200;">=</span> kCAFillRuleEvenOdd;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; shapeLayer.lineWidth <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>;<br />
&nbsp; &nbsp; &nbsp;shapeLayer.lineCap <span style="color: #002200;">=</span> kCALineCapRound;<br />
&nbsp; &nbsp; shapeLayer.strokeColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor blackColor<span style="color: #002200;">&#93;</span>.CGColor;<br />
&nbsp; &nbsp; shapeLayer.path <span style="color: #002200;">=</span> mainPath;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self.layer addSublayer<span style="color: #002200;">:</span>shapeLayer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; maskLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CAShapeLayer layer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; maskLayer.fillColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor grayColor<span style="color: #002200;">&#93;</span>.CGColor; <br />
&nbsp; &nbsp; &nbsp;maskLayer.fillRule <span style="color: #002200;">=</span> kCAFillRuleEvenOdd;<br />
&nbsp; &nbsp; maskLayer.path <span style="color: #002200;">=</span> mainPath;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>shapeLayer addSublayer<span style="color: #002200;">:</span>maskLayer<span style="color: #002200;">&#93;</span>;<br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; gradientLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CAGradientLayer layer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; gradientLayer.frame <span style="color: #002200;">=</span> self.bounds;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; gradientLayer.colors <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> arrayWithObjects<span style="color: #002200;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>UIColor lightGrayColor<span style="color: #002200;">&#93;</span>.CGColor,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>UIColor darkGrayColor<span style="color: #002200;">&#93;</span>.CGColor,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; gradientLayer.needsDisplayOnBoundsChange <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>shapeLayer addSublayer<span style="color: #002200;">:</span>gradientLayer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>gradientLayer setMask<span style="color: #002200;">:</span>maskLayer<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>gradientLayer setNeedsDisplay<span style="color: #002200;">&#93;</span>; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>animation<span style="color: #002200;">&#41;</span> withObject<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> afterDelay<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> animation <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; CABasicAnimation <span style="color: #002200;">*</span>_animation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CABasicAnimation animationWithKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;path&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;_animation.duration <span style="color: #002200;">=</span> <span style="color: #2400d9;">0.4</span>;<br />
&nbsp; &nbsp; &nbsp;_animation.timingFunction <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CAMediaTimingFunction functionWithName<span style="color: #002200;">:</span>kCAMediaTimingFunctionEaseInEaseOut<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; _animation.delegate <span style="color: #002200;">=</span> self;<br />
&nbsp; &nbsp; &nbsp;_animation.fromValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>__bridge <span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>mainPath;<br />
&nbsp; &nbsp; &nbsp;_animation.toValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>__bridge <span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>secondPath;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>shapeLayer addAnimation<span style="color: #002200;">:</span>_animation forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;animatePath&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>maskLayer addAnimation<span style="color: #002200;">:</span>_animation forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;animatePath&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>animationDidStop<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CAAnimation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>anim finished<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>flag <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; shapeLayer.path <span style="color: #002200;">=</span> secondPath;<br />
&nbsp; &nbsp; maskLayer.path <span style="color: #002200;">=</span> secondPath;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p>Result:<br />
<video width="362" height="540" controls="controls"><source src="http://www.developers-life.com/wp-content/uploads/2012/01/CAShapeLayer-with-gradient-Broadband.m4v" type="video/mp4"></video></p>
<p><a href="https://github.com/sakrist/layers" target="_blank"><img src="http://www.developers-life.com/wp-content/uploads/2011/08/github-logo-80px.png" alt="" title="github-logo-80px" width="130" height="80" class="alignnone size-full wp-image-1257" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/masked-shape-layer-with-gradient.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.developers-life.com/wp-content/uploads/2012/01/CAShapeLayer-with-gradient-Broadband.m4v" length="182231" type="video/mp4" />
		</item>
		<item>
		<title>Good post about CAShapeLayer</title>
		<link>http://www.developers-life.com/good-post-about-cashapelayer.html</link>
		<comments>http://www.developers-life.com/good-post-about-cashapelayer.html#comments</comments>
		<pubDate>Fri, 27 Jan 2012 10:16:46 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[CAShapeLayer]]></category>
		<category><![CDATA[CGPath]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1394</guid>
		<description><![CDATA[Animating the drawing of a CGPath with CAShapeLayer Thanks for Ole Begemann.]]></description>
			<content:encoded><![CDATA[<p><video width="384" height="512" controls="controls"><source src="http://oleb.net/media/AnimatedPathsHelloWorld.m4v" type="video/mp4"></video></p>
<p><a href="http://oleb.net/blog/2010/12/animating-drawing-of-cgpath-with-cashapelayer/" target="_blank">Animating the drawing of a CGPath with CAShapeLayer</a></p>
<p>Thanks for Ole Begemann.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/good-post-about-cashapelayer.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://oleb.net/media/AnimatedPathsHelloWorld.m4v" length="158421" type="video/mp4" />
		</item>
		<item>
		<title>UIBezierPath</title>
		<link>http://www.developers-life.com/uibezierpath.html</link>
		<comments>http://www.developers-life.com/uibezierpath.html#comments</comments>
		<pubDate>Fri, 27 Jan 2012 09:58:58 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[CALayer]]></category>
		<category><![CDATA[NSBezierPath]]></category>
		<category><![CDATA[rounded-rectangular]]></category>
		<category><![CDATA[UIBezierPath]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1390</guid>
		<description><![CDATA[UIBezierPath is a convenient object for creating rounded-rectangular shapes. Starting from 3.2, this class becomes public, but the interface is dramatically changed to match that of NSBezierPath. 12345678910-&#40;void&#41;drawRect:&#40;CGRect&#41;rect &#123; &#160; UIBezierPath* roundedRect = &#91;UIBezierPath roundedRectBezierPath:CGRectInset&#40;rect, 5, 5&#41; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>UIBezierPath is a convenient object for creating rounded-rectangular shapes.<br />
Starting from 3.2, this class becomes public, but the interface is dramatically changed to match that of <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSBezierPath_Class/Reference/Reference.html" target="_blank">NSBezierPath</a>.</p>
<p><a href="http://www.developers-life.com/wp-content/uploads/2012/01/471px-UIBezierPath_Examples.svg_.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/01/471px-UIBezierPath_Examples.svg_-300x156.png" alt="" title="UIBezierPath_Examples " width="300" height="156" class="alignnone size-medium wp-image-1391" /></a></p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawRect<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>rect <span style="color: #002200;">&#123;</span><br />
&nbsp; UIBezierPath<span style="color: #002200;">*</span> roundedRect <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIBezierPath roundedRectBezierPath<span style="color: #002200;">:</span>CGRectInset<span style="color: #002200;">&#40;</span>rect, <span style="color: #2400d9;">5</span>, <span style="color: #2400d9;">5</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;withRoundedCorners<span style="color: #002200;">:</span>UIBezierPathRoundedTopLeftCorner|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIBezierPathRoundedTopRightCorner|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIBezierPathRoundedBottomLeftCorner|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UIBezierPathRoundedBottomRightCorner<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;withCornerRadius<span style="color: #002200;">:</span><span style="color: #2400d9;">5</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIColor blackColor<span style="color: #002200;">&#93;</span> setFill<span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#91;</span>roundedRect fill<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p><a href="http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIBezierPath.h" target="_blank">UIBezierPath.h</a></p>
<p><noindex>from <a href="http://iphonedevwiki.net/index.php/UIBezierPath" target="_blank">iphonedevwiki.net</a></noindex></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/uibezierpath.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Convert one day to one minute</title>
		<link>http://www.developers-life.com/convert-one-day-to-one-minute.html</link>
		<comments>http://www.developers-life.com/convert-one-day-to-one-minute.html#comments</comments>
		<pubDate>Tue, 24 Jan 2012 16:06:39 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[AVAssetWriter]]></category>
		<category><![CDATA[AVAssetWriterInput]]></category>
		<category><![CDATA[AVCaptureDeviceInput]]></category>
		<category><![CDATA[AVCaptureVideoDataOutput]]></category>
		<category><![CDATA[AVFoundation]]></category>
		<category><![CDATA[QuartzCore]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1386</guid>
		<description><![CDATA[I create simple project for iOS, &#8220;One minute&#8221;. This project create video from photos on iOS device. Results of app:]]></description>
			<content:encoded><![CDATA[<p>I create simple project for iOS, &#8220;One minute&#8221;. This project create video from photos on iOS device.</p>
<p>Results of app:<br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/D1qLmZq9RmA" frameborder="0" allowfullscreen></iframe><br />
<span id="more-1386"></span><br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/s8BVlGTa5OU" frameborder="0" allowfullscreen></iframe><br />
<iframe width="560" height="315" src="http://www.youtube.com/embed/nPfB4fPNgLk" frameborder="0" allowfullscreen></iframe></p>
<p><a href="https://github.com/sakrist/One-minute"><img src="http://www.developers-life.com/wp-content/uploads/2011/08/github-logo-80px.png" alt="" title="github-logo-80px" width="130" height="80" class="alignnone size-full wp-image-1257" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/convert-one-day-to-one-minute.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSTableView with custom header</title>
		<link>http://www.developers-life.com/nstableview-with-custom-header.html</link>
		<comments>http://www.developers-life.com/nstableview-with-custom-header.html#comments</comments>
		<pubDate>Sun, 22 Jan 2012 12:04:16 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[NSCell]]></category>
		<category><![CDATA[NSTableHeaderCell]]></category>
		<category><![CDATA[NSTableView]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1378</guid>
		<description><![CDATA[Default header looks like this First we want change height of header: 12NSTableHeaderView *tableHeaderView = &#91;&#91;NSTableHeaderView alloc&#93; initWithFrame:NSMakeRect&#40;0, 0, 120, 60&#41;&#93;; &#160; &#160; &#91;_tableView setHeaderView:tableHeaderView&#93;; Next step we want change NSTableHeaderCell, can make category for this class or make subclass. So, I wrote subclass. Empty category Rewrite method for change style 123456789101112131415161718192021@implementation NSTableHeaderCell &#40;VBNSTableHeaderCell&#41; - [...]]]></description>
			<content:encoded><![CDATA[<p>Default header looks like this<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-1.25.57-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-1.25.57-PM-300x227.png" alt="" title="Default header NSTableView" width="300" height="227" class="alignnone size-medium wp-image-1379" /></a></p>
<p>First we want change height of header:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableHeaderView_Class/"><span style="color: #400080;">NSTableHeaderView</span></a> <span style="color: #002200;">*</span>tableHeaderView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableHeaderView_Class/"><span style="color: #400080;">NSTableHeaderView</span></a> alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>NSMakeRect<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">120</span>, <span style="color: #2400d9;">60</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_tableView setHeaderView<span style="color: #002200;">:</span>tableHeaderView<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Next step we want change NSTableHeaderCell, can make category for this class or make subclass. So, I wrote subclass.</p>
<p>Empty category<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-1.40.27-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-1.40.27-PM-273x300.png" alt="" title="NSTableView with custom header" width="273" height="300" class="alignnone size-medium wp-image-1381" /></a><br />
<span id="more-1378"></span><br />
Rewrite method for change style</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@implementation</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableHeaderCell_Class/"><span style="color: #400080;">NSTableHeaderCell</span></a> <span style="color: #002200;">&#40;</span>VBNSTableHeaderCell<span style="color: #002200;">&#41;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRect</span><span style="color: #002200;">&#41;</span>cellFrame inView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/"><span style="color: #400080;">NSView</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>controlView <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMutableParagraphStyle_Class/"><span style="color: #400080;">NSMutableParagraphStyle</span></a> <span style="color: #002200;">*</span> aParagraphStyle <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMutableParagraphStyle_Class/"><span style="color: #400080;">NSMutableParagraphStyle</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>aParagraphStyle setLineBreakMode<span style="color: #002200;">:</span>NSLineBreakByWordWrapping<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>aParagraphStyle setAlignment<span style="color: #002200;">:</span>NSCenterTextAlignment<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> <span style="color: #002200;">*</span>attrs <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/"><span style="color: #400080;">NSMutableDictionary</span></a> dictionaryWithDictionary<span style="color: #002200;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self attributedStringValue<span style="color: #002200;">&#93;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;attributesAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;effectiveRange<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mutableCopy<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>attrs setObject<span style="color: #002200;">:</span>aParagraphStyle forKey<span style="color: #002200;">:</span>NSParagraphStyleAttributeName<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSGradient_Class/"><span style="color: #400080;">NSGradient</span></a> <span style="color: #002200;">*</span>grayGradient <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSGradient_Class/"><span style="color: #400080;">NSGradient</span></a> alloc<span style="color: #002200;">&#93;</span> initWithColorsAndLocations<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSColor_Class/"><span style="color: #400080;">NSColor</span></a> colorWithDeviceWhite<span style="color: #002200;">:</span><span style="color: #2400d9;">0.95</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>, <span style="color: #2400d9;">0.1</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSColor_Class/"><span style="color: #400080;">NSColor</span></a> colorWithDeviceWhite<span style="color: #002200;">:</span><span style="color: #2400d9;">0.5</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>, <span style="color: #2400d9;">0.9</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>grayGradient drawInRect<span style="color: #002200;">:</span>cellFrame angle<span style="color: #002200;">:</span><span style="color: #2400d9;">90</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self stringValue<span style="color: #002200;">&#93;</span> drawInRect<span style="color: #002200;">:</span>cellFrame withAttributes<span style="color: #002200;">:</span>attrs<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #a61390;">@end</span></div></td></tr></tbody></table></div>
<p><a href="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-2.00.52-PM.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-22-at-2.00.52-PM-300x196.png" alt="" title="NSTableView with custom header, result" width="300" height="196" class="alignnone size-medium wp-image-1383" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/nstableview-with-custom-header.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIColor from hex</title>
		<link>http://www.developers-life.com/uicolor-from-hex.html</link>
		<comments>http://www.developers-life.com/uicolor-from-hex.html#comments</comments>
		<pubDate>Tue, 10 Jan 2012 12:40:23 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[HTML color to UIColor]]></category>
		<category><![CDATA[UIColor]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=1363</guid>
		<description><![CDATA[I added 2 new methods to category UIColor. 123456789101112131415161718+ &#40;UIColor* &#41; colorWithHex:&#40;int&#41;color &#123; &#160; &#160; float red = &#40;color &#38; 0xff000000&#41; &#62;&#62; 24; &#160; &#160; float green = &#40;color &#38; 0x00ff0000&#41; &#62;&#62; 16; &#160; &#160; float blue = &#40;color &#38; 0x0000ff00&#41; &#62;&#62; 8; &#160; &#160; float alpha = &#40;color &#38; 0x000000ff&#41;; &#160; &#160; return &#91;UIColor [...]]]></description>
			<content:encoded><![CDATA[<p>I added 2 new methods to category UIColor.</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>UIColor<span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span> colorWithHex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>color <span style="color: #002200;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #a61390;">float</span> red <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>color <span style="color: #002200;">&amp;</span> 0xff000000<span style="color: #002200;">&#41;</span> &gt;&gt; <span style="color: #2400d9;">24</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">float</span> green <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>color <span style="color: #002200;">&amp;</span> 0x00ff0000<span style="color: #002200;">&#41;</span> &gt;&gt; <span style="color: #2400d9;">16</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">float</span> blue <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>color <span style="color: #002200;">&amp;</span> 0x0000ff00<span style="color: #002200;">&#41;</span> &gt;&gt; <span style="color: #2400d9;">8</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">float</span> alpha <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>color <span style="color: #002200;">&amp;</span> 0x000000ff<span style="color: #002200;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>UIColor colorWithRed<span style="color: #002200;">:</span>red<span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span> green<span style="color: #002200;">:</span>green<span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span> blue<span style="color: #002200;">:</span>blue<span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span> alpha<span style="color: #002200;">:</span>alpha<span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> colorWithHexRed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>red green<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">char</span><span style="color: #002200;">&#41;</span>green blue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">char</span><span style="color: #002200;">&#41;</span>blue alpha<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">char</span><span style="color: #002200;">&#41;</span>alpha <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">int</span> x <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; x |<span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>red <span style="color: #002200;">&amp;</span> 0xff<span style="color: #002200;">&#41;</span> &lt;&lt; <span style="color: #2400d9;">24</span>;<br />
&nbsp; &nbsp; x |<span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>green <span style="color: #002200;">&amp;</span> 0xff<span style="color: #002200;">&#41;</span> &lt;&lt; <span style="color: #2400d9;">16</span>;<br />
&nbsp; &nbsp; x |<span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>blue <span style="color: #002200;">&amp;</span> 0xff<span style="color: #002200;">&#41;</span> &lt;&lt; <span style="color: #2400d9;">8</span>;<br />
&nbsp; &nbsp; x |<span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>alpha <span style="color: #002200;">&amp;</span> 0xff<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>UIColor colorWithHex<span style="color: #002200;">:</span>x<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>Example:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">UIColor <span style="color: #002200;">*</span>redColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor colorWithHex<span style="color: #002200;">:</span>0xff0000ff<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>First 6 symbols like HTML color, latest 2 symbols it&#8217;s alpha.</p>
<p><a href="https://github.com/sakrist/UIColor-i7HexColor" target="_blank"><img src="http://www.developers-life.com/wp-content/uploads/2011/08/github-logo-80px.png" alt="" title="github-logo-80px" width="130" height="80" class="alignnone size-full wp-image-1257" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/uicolor-from-hex.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

