<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Notes of a Developer</title><link>http://www.developers-life.com</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sakrist/iphone" /><description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description><language>en</language><lastBuildDate>Thu, 09 Feb 2012 06:12:11 PST</lastBuildDate><generator>http://wordpress.org/?v=3.3.1</generator><sy:updatePeriod xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">hourly</sy:updatePeriod><sy:updateFrequency xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">1</sy:updateFrequency><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sakrist/iphone" /><feedburner:info uri="sakrist/iphone" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by/2.0/</creativeCommons:license><feedburner:emailServiceId>sakrist/iphone</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>AsyncURLConnection with pause/resume and progress +block’s</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/jAXG_asLPRk/asyncurlconnection-with-pauseresume-and-progress-blocks.html</link><category>iOS</category><category>Mac OS X</category><category>AsyncURLConnection</category><category>blocks</category><category>NSMutableURLRequest</category><category>NSProgressIndicator</category><category>pause</category><category>resume</category><category>URLConnection</category><category>User-Agent</category><category>__block</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Tue, 07 Feb 2012 15:03:55 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1445</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I rewrite one class with async connection, and add progress block and pause/resume.</p>
<p>Example usage:</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 /></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/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>comboUrl <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://support.apple.com/downloads/DL1484/en_US/MacOSXUpdCombo10.7.3.dmg&quot;</span>;<br />
AsyncURLConnection <span style="color: #002200;">*</span>aConnection <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>AsyncURLConnection request<span style="color: #002200;">:</span>comboUrl <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; completeBlock<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span>data, <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>url<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>data writeToFile<span style="color: #002200;">:</span>filename atomically<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span> errorBlock<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><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;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &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;Error %f&quot;</span>, error<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span> progress<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span> progress<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_global_queue<span style="color: #002200;">&#40;</span>DISPATCH_QUEUE_PRIORITY_DEFAULT, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">/* process downloaded data in Concurrent Queue */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_main_queue<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">/* update UI on Main Thread */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &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;progress %f&quot;</span>, progress<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Very easy to use blocks of AsyncURLConnection (aka async URLConnection) and NSProgressIndicator indicator. You can implement progress bar of downloading in your mac os x application like this 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 />2<br />3<br />4<br />5<br />6<br />7<br />8<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/NSProgressIndicator_Class/"><span style="color: #400080;">NSProgressIndicator</span></a> <span style="color: #002200;">*</span>horizontal <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/NSProgressIndicator_Class/"><span style="color: #400080;">NSProgressIndicator</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;">200</span>, <span style="color: #2400d9;">300</span>, <span style="color: #2400d9;">200</span>, <span style="color: #2400d9;">12</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal setStyle<span style="color: #002200;">:</span>NSProgressIndicatorBarStyle<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal setIndeterminate<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal setControlSize<span style="color: #002200;">:</span>NSSmallControlSize<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal setDisplayedWhenStopped<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal setMaxValue<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self addSubview<span style="color: #002200;">:</span>horizontal<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>horizontal release<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>And just set progress value.</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 /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;progress<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span> progress<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_global_queue<span style="color: #002200;">&#40;</span>DISPATCH_QUEUE_PRIORITY_DEFAULT, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">/* process downloaded data in Concurrent Queue */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_main_queue<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">/* update UI on Main Thread */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">&#91;</span>horizontal setDoubleValue<span style="color: #002200;">:</span>progress<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p><span id="more-1445"></span><br />
Result:<br />
<a href="http://www.developers-life.com/wp-content/uploads/2012/02/NSProgressIndicator+AsyncURLConnection.png"><img src="http://www.developers-life.com/wp-content/uploads/2012/02/NSProgressIndicator+AsyncURLConnection.png" alt="" title="NSProgressIndicator+AsyncURLConnection" width="251" height="60" class="alignnone size-full wp-image-1446" /></a></p>
<p>You can modify request header in block like in this 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 />2<br />3<br />4<br />5<br />6<br />7<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;AsyncURLConnection <span style="color: #002200;">*</span>aURLConnection <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>AsyncURLConnection request<span style="color: #002200;">:</span>url_string <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;modifyRequest<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/"><span style="color: #400080;">NSMutableURLRequest</span></a> <span style="color: #002200;">*</span>request<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>request setValue<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iTunes/10.5.3 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/534.53.11&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;forHTTPHeaderField<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;User-Agent&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; completeBlock<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span>data, <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>url<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span> <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorBlock<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><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;">&#41;</span> <span style="color: #002200;">&#123;</span> <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>pause and resume</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 /></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;">&#91;</span>aURLConnection pause<span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>aURLConnection isPause<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>aURLConnection resume<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p><a href="https://github.com/sakrist/ASyncURLConnection" title="Project on GitHub" target="_blank"><img src="http://www.developers-life.com/wp-content/uploads/2011/08/github-logo-80px.png" alt="" width="130" height="80" class="alignnone size-full wp-image-1257" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/1MXJ9JSqiByJKvMQabF_4dyRm78/0/da"><img src="http://feedads.g.doubleclick.net/~a/1MXJ9JSqiByJKvMQabF_4dyRm78/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1MXJ9JSqiByJKvMQabF_4dyRm78/1/da"><img src="http://feedads.g.doubleclick.net/~a/1MXJ9JSqiByJKvMQabF_4dyRm78/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>I rewrite one class with async connection, and add progress block and pause/resume. Example usage: 123456789101112131415NSString *comboUrl = @&amp;#34;http://support.apple.com/downloads/DL1484/en_US/MacOSXUpdCombo10.7.3.dmg&amp;#34;; AsyncURLConnection *aConnection = &amp;#91;AsyncURLConnection request:comboUrl &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; completeBlock:^&amp;#40;NSData *data, NSString *url&amp;#41; &amp;#123; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#91;data writeToFile:filename atomically:NO&amp;#93;; &amp;#160; &amp;#160; &amp;#160; [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/asyncurlconnection-with-pauseresume-and-progress-blocks.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/asyncurlconnection-with-pauseresume-and-progress-blocks.html</feedburner:origLink></item><item><title>ANSI escape sequences for coloring</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/AtwnwulrdW0/ansi-escape-sequences-for-coloring.html</link><category>Mac OS X</category><category>ANSI</category><category>GeekTool</category><category>Terminal</category><category>Twitter</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Thu, 02 Feb 2012 03:06:07 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1434</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/RoQ4yPWuXq96MHRqi-eO-nn-Cx0/0/da"><img src="http://feedads.g.doubleclick.net/~a/RoQ4yPWuXq96MHRqi-eO-nn-Cx0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/RoQ4yPWuXq96MHRqi-eO-nn-Cx0/1/da"><img src="http://feedads.g.doubleclick.net/~a/RoQ4yPWuXq96MHRqi-eO-nn-Cx0/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>More about ANSI escape code I modify my twitter script from previous post and now timeline looks like this:</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/ansi-escape-sequences-for-coloring.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/ansi-escape-sequences-for-coloring.html</feedburner:origLink></item><item><title>My Modified Neon(author zb3k) Bowtie theme</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/d33OtYnjwb4/modified-neonby-zb3k-bowtie-theme.html</link><category>Mac OS X</category><category>album art</category><category>Bowtie</category><category>iTunes</category><category>theme</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Thu, 02 Feb 2012 01:04:47 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1429</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/xgUjN0xzkyO7rcQdkWinluGrGpU/0/da"><img src="http://feedads.g.doubleclick.net/~a/xgUjN0xzkyO7rcQdkWinluGrGpU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xgUjN0xzkyO7rcQdkWinluGrGpU/1/da"><img src="http://feedads.g.doubleclick.net/~a/xgUjN0xzkyO7rcQdkWinluGrGpU/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>If album does not has artwork: Download theme</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/modified-neonby-zb3k-bowtie-theme.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/modified-neonby-zb3k-bowtie-theme.html</feedburner:origLink></item><item><title>How to get twitter timeline in Command line (for GeekTool)</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/HjvJm_0jJVI/how-to-get-twitter-timeline-in-command-line-for-geektool.html</link><category>Mac OS X</category><category>GeekTool</category><category>gem</category><category>ruby</category><category>Twitter</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Tue, 31 Jan 2012 13:32:55 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1421</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/a19t1Po5cHepz-uBfb1CrfTrKR0/0/da"><img src="http://feedads.g.doubleclick.net/~a/a19t1Po5cHepz-uBfb1CrfTrKR0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/a19t1Po5cHepz-uBfb1CrfTrKR0/1/da"><img src="http://feedads.g.doubleclick.net/~a/a19t1Po5cHepz-uBfb1CrfTrKR0/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>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 &amp;#124;config&amp;#124; &amp;#160; config.consumer_key = &amp;#34;Consumer key&amp;#34; &amp;#160; config.consumer_secret = &amp;#34;Consumer secret&amp;#34; &amp;#160; config.oauth_token [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/how-to-get-twitter-timeline-in-command-line-for-geektool.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/how-to-get-twitter-timeline-in-command-line-for-geektool.html</feedburner:origLink></item><item><title>Chrome deviceorientation event in javascript</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/2OYnxO7Mpeo/chrome-deviceorientation-event-in-javascript.html</link><category>Android</category><category>Google</category><category>Javascript</category><category>Chrome</category><category>deviceorientation</category><category>event</category><category>JS</category><category>window.addEventListener</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Mon, 30 Jan 2012 14:01:24 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1412</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p><img src="http://www.blog.spoongraphics.co.uk/wp-content/uploads/2011/colourful-logo/18.jpg" id="testlogo" width="150" height="127"><br />
<script language="javascript">function onOrientation(event) {
        var rotate = 'rotate(' + event.gamma + 'deg)';
        var scale = 'scale(' + ((event.beta/180)*2 + 1) + ')';
        document.getElementById('testlogo').style.webkitTransform = rotate + ' ' + scale;
}window.addEventListener('deviceorientation', onOrientation);</script></p>
<p>Video:<br />
<iframe width="480" height="360" src="http://www.youtube.com/embed/509sfdQ4uPg" frameborder="0" allowfullscreen></iframe><br />
<span id="more-1412"></span></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 /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;script language<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;javascript&quot;</span>&gt;<br />
function onOrientation<span style="color: #002200;">&#40;</span>event<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; var rotate <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'rotate('</span> <span style="color: #002200;">+</span> event.gamma <span style="color: #002200;">+</span> <span style="color: #bf1d1a;">'deg)'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; var scale <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'scale('</span> <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>event.beta<span style="color: #002200;">/</span><span style="color: #2400d9;">180</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span><span style="color: #2400d9;">2</span> <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">+</span> <span style="color: #bf1d1a;">')'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">'testlogo'</span><span style="color: #002200;">&#41;</span>.style.webkitTransform <span style="color: #002200;">=</span> rotate <span style="color: #002200;">+</span> <span style="color: #bf1d1a;">' '</span> <span style="color: #002200;">+</span> scale;<br />
<span style="color: #002200;">&#125;</span><br />
window.addEventListener<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">'deviceorientation'</span>, onOrientation<span style="color: #002200;">&#41;</span>;<br />
&lt;<span style="color: #002200;">/</span>script&gt;</div></td></tr></tbody></table></div>

<p><a href="http://feedads.g.doubleclick.net/~a/wO7CyVFV79SUWrAotE8ROWtArag/0/da"><img src="http://feedads.g.doubleclick.net/~a/wO7CyVFV79SUWrAotE8ROWtArag/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wO7CyVFV79SUWrAotE8ROWtArag/1/da"><img src="http://feedads.g.doubleclick.net/~a/wO7CyVFV79SUWrAotE8ROWtArag/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>Video: 12345678&amp;#60;script language=&amp;#34;javascript&amp;#34;&amp;#62; function onOrientation&amp;#40;event&amp;#41; &amp;#123; &amp;#160; &amp;#160; &amp;#160; &amp;#160; var rotate = 'rotate(' + event.gamma + 'deg)'; &amp;#160; &amp;#160; &amp;#160; &amp;#160; var scale = 'scale(' + &amp;#40;&amp;#40;event.beta/180&amp;#41;*2 + 1&amp;#41; + ')'; &amp;#160; &amp;#160; &amp;#160; &amp;#160; document.getElementById&amp;#40;'testlogo'&amp;#41;.style.webkitTransform = rotate + ' ' + scale; &amp;#125; window.addEventListener&amp;#40;'deviceorientation', onOrientation&amp;#41;; &amp;#60;/script&amp;#62;</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/chrome-deviceorientation-event-in-javascript.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/chrome-deviceorientation-event-in-javascript.html</feedburner:origLink></item><item><title>Create movie from array of images</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/6m5iJrrFEUE/create-movie-from-array-of-images.html</link><category>iOS</category><category>iPad</category><category>iPhone</category><category>AVAssetWriter</category><category>AVAssetWriterInput</category><category>AVCaptureDeviceInput</category><category>AVCaptureVideoDataOutput</category><category>AVFoundation</category><category>QuartzCore</category><category>Video</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Mon, 30 Jan 2012 13:22:59 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1407</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/zh4tt80m3KcDEYlgqgvb-ZuIfPg/0/da"><img src="http://feedads.g.doubleclick.net/~a/zh4tt80m3KcDEYlgqgvb-ZuIfPg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zh4tt80m3KcDEYlgqgvb-ZuIfPg/1/da"><img src="http://feedads.g.doubleclick.net/~a/zh4tt80m3KcDEYlgqgvb-ZuIfPg/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>Create movie from images seq. First part of method, initialize 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950- &amp;#40;void&amp;#41; writeImagesAsMovie:&amp;#40;NSArray *&amp;#41;array toPath:&amp;#40;NSString*&amp;#41;path &amp;#123; &amp;#160; &amp;#160; NSString *documents = &amp;#91;NSSearchPathForDirectoriesInDomains &amp;#40;NSDocumentDirectory, NSUserDomainMask, YES&amp;#41; objectAtIndex: 0&amp;#93;; &amp;#160; &amp;#160; documents = &amp;#91;documents stringByAppendingPathComponent:currentWorkspace&amp;#93;; &amp;#160; &amp;#160; &amp;#160; &amp;#160; //NSLog(path); &amp;#160; &amp;#160; NSString *filename = &amp;#91;documents stringByAppendingPathComponent:&amp;#91;array objectAtIndex:0&amp;#93;&amp;#93;; &amp;#160; &amp;#160; UIImage *first = &amp;#91;UIImage imageWithContentsOfFile:filename&amp;#93;; &amp;#160; &amp;#160; [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/create-movie-from-array-of-images.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/create-movie-from-array-of-images.html</feedburner:origLink></item><item><title>Masked Shape layer with gradient</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/NcecoIsARTA/masked-shape-layer-with-gradient.html</link><category>iOS</category><category>CABasicAnimation</category><category>CAGradientLayer</category><category>CALayer</category><category>CAShapeLayer</category><category>CGMutablePathRef</category><category>QuartzCore</category><category>UIView</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Sat, 28 Jan 2012 06:07:19 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1396</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/ClhZaIRkGVyBCBTzAmZOA_enTVQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/ClhZaIRkGVyBCBTzAmZOA_enTVQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ClhZaIRkGVyBCBTzAmZOA_enTVQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/ClhZaIRkGVyBCBTzAmZOA_enTVQ/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>Layer with CGPathRef and animated. And added masked gradient for layer. ViewLayers.h 12345678910111213141516171819202122232425262728293031// // &amp;#160;ViewLayers.h // &amp;#160;layers // // &amp;#160;Created by Volodymyr Boichentsov on 1/28/12. // &amp;#160;Copyright (c) 2012 www.injoit.com. All rights reserved. // #import &amp;#60;UIKit/UIKit.h&amp;#62; #import &amp;#60;QuartzCore/QuartzCore.h&amp;#62; @interface ViewLayers : UIView &amp;#123; &amp;#160; &amp;#160; CGRect firstRect; &amp;#160; &amp;#160; CGRect secondRect; &amp;#160; &amp;#160; &amp;#160; &amp;#160; [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/masked-shape-layer-with-gradient.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://www.developers-life.com/masked-shape-layer-with-gradient.html</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/sakrist/iphone/~5/CMIYa8eVkyg/CAShapeLayer-with-gradient-Broadband.m4v" length="182231" type="video/mp4" /><feedburner:origEnclosureLink>http://www.developers-life.com/wp-content/uploads/2012/01/CAShapeLayer-with-gradient-Broadband.m4v</feedburner:origEnclosureLink></item><item><title>Good post about CAShapeLayer</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/7t8iDMr2gtE/good-post-about-cashapelayer.html</link><category>iOS</category><category>Animation</category><category>CAShapeLayer</category><category>CGPath</category><category>Video</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Fri, 27 Jan 2012 02:16:46 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1394</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/niRlzQ-t5qtTKFe-FoKcDtrKxEM/0/da"><img src="http://feedads.g.doubleclick.net/~a/niRlzQ-t5qtTKFe-FoKcDtrKxEM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/niRlzQ-t5qtTKFe-FoKcDtrKxEM/1/da"><img src="http://feedads.g.doubleclick.net/~a/niRlzQ-t5qtTKFe-FoKcDtrKxEM/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>Animating the drawing of a CGPath with CAShapeLayer Thanks for Ole Begemann.</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/good-post-about-cashapelayer.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/good-post-about-cashapelayer.html</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/sakrist/iphone/~5/Rrv9rI4wCYg/AnimatedPathsHelloWorld.m4v" length="158421" type="video/mp4" /><feedburner:origEnclosureLink>http://oleb.net/media/AnimatedPathsHelloWorld.m4v</feedburner:origEnclosureLink></item><item><title>UIBezierPath</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/SOBQHK5QfRU/uibezierpath.html</link><category>iOS</category><category>CALayer</category><category>NSBezierPath</category><category>rounded-rectangular</category><category>UIBezierPath</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Fri, 27 Jan 2012 01:58:58 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1390</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/4-2nfx8ahFph2MB_CuHL_NZqdfo/0/da"><img src="http://feedads.g.doubleclick.net/~a/4-2nfx8ahFph2MB_CuHL_NZqdfo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/4-2nfx8ahFph2MB_CuHL_NZqdfo/1/da"><img src="http://feedads.g.doubleclick.net/~a/4-2nfx8ahFph2MB_CuHL_NZqdfo/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>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-&amp;#40;void&amp;#41;drawRect:&amp;#40;CGRect&amp;#41;rect &amp;#123; &amp;#160; UIBezierPath* roundedRect = &amp;#91;UIBezierPath roundedRectBezierPath:CGRectInset&amp;#40;rect, 5, 5&amp;#41; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/uibezierpath.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">2</slash:comments><feedburner:origLink>http://www.developers-life.com/uibezierpath.html</feedburner:origLink></item><item><title>Convert one day to one minute</title><link>http://feedproxy.google.com/~r/sakrist/iphone/~3/ImS5Y_TAaSo/convert-one-day-to-one-minute.html</link><category>iOS</category><category>AVAssetWriter</category><category>AVAssetWriterInput</category><category>AVCaptureDeviceInput</category><category>AVCaptureVideoDataOutput</category><category>AVFoundation</category><category>QuartzCore</category><category>Video</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vladimir Boychentsov</dc:creator><pubDate>Tue, 24 Jan 2012 08:06:39 PST</pubDate><guid isPermaLink="false">http://www.developers-life.com/?p=1386</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![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>

<p><a href="http://feedads.g.doubleclick.net/~a/jiV_YStoTegBxa34kzshnnZgVxU/0/da"><img src="http://feedads.g.doubleclick.net/~a/jiV_YStoTegBxa34kzshnnZgVxU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jiV_YStoTegBxa34kzshnnZgVxU/1/da"><img src="http://feedads.g.doubleclick.net/~a/jiV_YStoTegBxa34kzshnnZgVxU/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded><description>I create simple project for iOS, &amp;#8220;One minute&amp;#8221;. This project create video from photos on iOS device. Results of app:</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.developers-life.com/convert-one-day-to-one-minute.html/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.developers-life.com/convert-one-day-to-one-minute.html</feedburner:origLink></item></channel></rss>

