<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>joshua welcomes you</title>
	<atom:link href="http://joshualay.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshualay.net/blog</link>
	<description>awesome + misc (tm)</description>
	<lastBuildDate>Tue, 30 Apr 2013 14:54:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Using NSExpression to evaluate arithmetic</title>
		<link>http://joshualay.net/blog/2013/04/using-nsexpression-to-evaluate-arithmetic/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-nsexpression-to-evaluate-arithmetic</link>
		<comments>http://joshualay.net/blog/2013/04/using-nsexpression-to-evaluate-arithmetic/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 14:54:20 +0000</pubDate>
		<dc:creator>Joshua Lay</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[NSExpression]]></category>

		<guid isPermaLink="false">http://joshualay.net/blog/?p=2158</guid>
		<description><![CDATA[Today I found something cool in the form of NSExpression. I wanted to be able to evaluate arithmetic represented as an NSString without having to write too much code. Using NSExpression it's a two step operation. stackoverflow answer NSExpression *expression = [NSExpression expressionWithFormat:@"9+4"]; // result is a NSNumber id result = [expression expressionValueWithObject:nil context:nil];]]></description>
				<content:encoded><![CDATA[<p>Today I found something cool in the form of <a href="http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Classes/NSExpression_Class/Reference/NSExpression.html" title="NSExpression Apple Docs">NSExpression</a>.</p>
<p>I wanted to be able to evaluate arithmetic represented as an NSString without having to write too much code. Using NSExpression it's a two step operation.</p>
<p><a href="http://stackoverflow.com/a/8870506" title="Stackoverflow answer">stackoverflow answer</a></p>
<pre><code>NSExpression *expression = [NSExpression expressionWithFormat:@"9+4"];
// result is a NSNumber
id result = [expression expressionValueWithObject:nil context:nil]; 
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://joshualay.net/blog/2013/04/using-nsexpression-to-evaluate-arithmetic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JLPeekModal</title>
		<link>http://joshualay.net/blog/2013/03/jlpeakmodal/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jlpeakmodal</link>
		<comments>http://joshualay.net/blog/2013/03/jlpeakmodal/#comments</comments>
		<pubDate>Sat, 30 Mar 2013 09:44:48 +0000</pubDate>
		<dc:creator>Joshua Lay</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[my life]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://joshualay.net/blog/?p=2151</guid>
		<description><![CDATA[I wanted to have a go at creating a half modal slide transition. The intention for this is if you want the user to be able to see the contents of the previous view controller and a partial amount of the one you've just pushed on. Check out JLPeekModal on Github. There are a few [...]]]></description>
				<content:encoded><![CDATA[<p>I wanted to have a go at creating a half modal slide transition. The intention for this is if you want the user to be able to see the contents of the previous view controller and a partial amount of the one you've just pushed on.</p>
<p>Check out <a href="https://github.com/joshualay/JLPeekModal">JLPeekModal on Github</a>.</p>
<p>There are a few options which I need to refactor to allow for more obvious customisation. I'm hoping the code is readable enough for that already :)</p>
]]></content:encoded>
			<wfw:commentRss>http://joshualay.net/blog/2013/03/jlpeakmodal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIBarButton background image customisation</title>
		<link>http://joshualay.net/blog/2013/03/uibarbutton-background-image-customisation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=uibarbutton-background-image-customisation</link>
		<comments>http://joshualay.net/blog/2013/03/uibarbutton-background-image-customisation/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 03:06:46 +0000</pubDate>
		<dc:creator>Joshua Lay</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[UIAppearance]]></category>
		<category><![CDATA[UIBarButtonItem]]></category>

		<guid isPermaLink="false">http://joshualay.net/blog/?p=2147</guid>
		<description><![CDATA[If you've changed the tint colour of your UINavigationBar or you just want to get away from Apple's default UIBarButtonItem styles then UIAppearance can help you out again. Please note that this is for iOS 6.0+. In iOS 5.0 you can only customise the Back button without having to create a subclass UIImage* plainBtn = [...]]]></description>
				<content:encoded><![CDATA[<p>If you've changed the tint colour of your UINavigationBar or you just want to get away from Apple's default UIBarButtonItem styles then UIAppearance can help you out again.</p>
<p><strong>Please note that this is for iOS 6.0+. In iOS 5.0 you can only customise the Back button without having to create a subclass</strong></p>
<pre><code>UIImage* plainBtn = [[UIImage imageNamed:@"btn"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
UIImage* plainBtnHighlight = [[UIImage imageNamed:@"btn-high"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];

UIImage* doneBtn = [[UIImage imageNamed:@"btn-done"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
UIImage* doneBtnHighlight = [[UIImage imageNamed:@"btn-done-high"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];

// Set the background images for all plain style buttons
[[UIBarButtonItem appearance] setBackgroundImage:plainBtn forState:UIControlStateNormal style:UIBarButtonItemStylePlain barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:plainBtnHighlight forState:UIControlStateHighlighted style:UIBarButtonItemStylePlain barMetrics:UIBarMetricsDefault];

// Set the background images for all of our done style buttons
[[UIBarButtonItem appearance] setBackgroundImage:doneBtn forState:UIControlStateNormal style:UIBarButtonItemStyleDone barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:doneBtnHighlight forState:UIControlStateHighlighted style:UIBarButtonItemStyleDone barMetrics:UIBarMetricsDefault];
</code></pre>
<p>Documentation for this method is here: <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html#//apple_ref/occ/instm/UIBarButtonItem/setBackgroundImage:forState:style:barMetrics:" title="setBackgroundImage:forState:style:barMetrics: documentation">UIBarButtonItem - setBackgroundImage:forState:style:barMetrics:</a></p>
<p>Something to watch out for if you're doing custom text attributes for your UIBarButtonItem's. E.g.</p>
<pre><code>[[UIBarButtonItem appearance] setTitleTextAttributes:attrsNormal forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:attrsHighlighted forState:UIControlStateHighlighted];
</code></pre>
<p>This goes for all of your UIBarButtonItem's in your app. What this means is if you had a white <strong>plainBtn</strong> image and a very dark <strong>doneBtn</strong> image you may have to watch out what <a href="http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSString_UIKit_Additions/Reference/Reference.html">UITextAttributeTextColor</a> you set. E.g. if you set a black colour then it might not be seen on the Done buttons.</p>
<p>One way I found to get around this is making your root view a <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html">UINavigationController</a> and setting itself as a <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UINavigationControllerDelegate">UINavigationControllerDelegate</a>.</p>
<p>You can then implement the delegate method <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UINavigationControllerDelegate/navigationController:willShowViewController:animated:">navigationController:willShowViewController:animated:</a>:</p>
<pre><code>#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSDictionary* attrs = @{UITextAttributeTextColor: [UIColor whiteColor]};
    for (UIBarButtonItem* rightBarButton in viewController.navigationItem.rightBarButtonItems)
    {
        if (rightBarButton.style == UIBarButtonItemStylePlain || rightBarButton.style == UIBarButtonItemStyleDone)
        {
            [rightBarButton setTitleTextAttributes:attrs forState:UIControlStateNormal];
            [rightBarButton setTitleTextAttributes:attrs forState:UIControlStateHighlighted];
        }
    }
}
</code></pre>
<p>It's kind of a cheat; but I haven't found a better solution to making sure your Plain and Done buttons have different title text attributes.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshualay.net/blog/2013/03/uibarbutton-background-image-customisation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS development &#8211; UINavigationBar changing the text title attributes</title>
		<link>http://joshualay.net/blog/2013/03/ios-development-uinavigationbar-changing-the-text-title-attributes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ios-development-uinavigationbar-changing-the-text-title-attributes</link>
		<comments>http://joshualay.net/blog/2013/03/ios-development-uinavigationbar-changing-the-text-title-attributes/#comments</comments>
		<pubDate>Sat, 23 Mar 2013 07:05:21 +0000</pubDate>
		<dc:creator>Joshua Lay</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[UIAppearance]]></category>
		<category><![CDATA[UINavigationBar]]></category>

		<guid isPermaLink="false">http://joshualay.net/blog/?p=2143</guid>
		<description><![CDATA[For a recent project I wanted to change all titles in my UINavigationController stack to a custom font. With the UIAppearance protocol this is really quite simple: [[UINavigationBar appearance] setTitleTextAttributes:attrs]; attrs is an NSDictionary that is made up of Keys For Text Attribute Dictionaries NSString *const UITextAttributeFont; NSString *const UITextAttributeTextColor; NSString *const UITextAttributeTextShadowColor; NSString *const [...]]]></description>
				<content:encoded><![CDATA[<p>For a recent project I wanted to change all titles in my UINavigationController stack to a custom font.</p>
<p>With the <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html" title="UIAppearance Protocol Reference">UIAppearance protocol</a> this is really quite simple:</p>
<pre><code>[[UINavigationBar appearance] setTitleTextAttributes:attrs];
</code></pre>
<p><strong>attrs</strong> is an NSDictionary that is made up of <a href="http://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSString_UIKit_Additions/Reference/Reference.html#//apple_ref/doc/uid/TP40006893" title="NSString UIKit Additions Reference">Keys For Text Attribute Dictionaries</a></p>
<pre><code>NSString *const UITextAttributeFont;
NSString *const UITextAttributeTextColor;
NSString *const UITextAttributeTextShadowColor;
NSString *const UITextAttributeTextShadowOffset;
</code></pre>
<p>E.g. To change all the titles to blue.</p>
<pre><code>NSDictionary* attrs = @{ UITextAttributeTextColor: [UIColor blueColor] };
[[UINavigationBar appearance] setTitleTextAttributes:attrs];
</code></pre>
<p>Something to note when setting a custom font; the base line may be higher than a system font. I think this partly due to how the font is created but don't hold me to that one. In order to adjust the base line height you just need to do this:</p>
<pre><code>[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:3.5f forBarMetrics:UIBarMetricsDefault];
</code></pre>
<p>Play around with the vertical adjustment value to get it looking correct again.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshualay.net/blog/2013/03/ios-development-uinavigationbar-changing-the-text-title-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS development &#8211; Saving UILabel as UIImage</title>
		<link>http://joshualay.net/blog/2013/03/ios-development-saving-uilabel-as-uiimage/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ios-development-saving-uilabel-as-uiimage</link>
		<comments>http://joshualay.net/blog/2013/03/ios-development-saving-uilabel-as-uiimage/#comments</comments>
		<pubDate>Sat, 16 Mar 2013 01:37:38 +0000</pubDate>
		<dc:creator>Joshua Lay</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://joshualay.net/blog/?p=2140</guid>
		<description><![CDATA[Recently I needed a way to use a custom icon font (e.g. Font Awesome and save the results out as an image. It turns out this isn't too hard (with some help from Stackoverflow). I've written a gist to save out a UILabel as a UIImage. This category makes a few assumptions: You're only creating [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I needed a way to use a custom icon font (e.g. <a href="http://fortawesome.github.com/Font-Awesome/" title="Font awesome">Font Awesome</a> and save the results out as an image. It turns out this isn't too hard (with some help from Stackoverflow).</p>
<p>I've written a <a href="https://gist.github.com/joshualay/5139620" title="UILabel to UIImage Gist">gist</a> to save out a UILabel as a UIImage.</p>
<p>This category makes a few assumptions:</p>
<ul>
<li>You're only creating an image for a single letter from an icon font</li>
<li>You want to save out the image to file and load from that</li>
</ul>
<p>Once an image is created it will be loaded each and every time. If you're going to be actively changing the icon font I'd recommend commenting out the saving code. I'd also recommend putting in a job on app load to clear out the PNG files created every couple of weeks in case of updates.</p>
<p>The creation of a PNG file for loading later isn't really required as the creation of a UIImage is very fast.</p>
<p><span id="more-2140"></span></p>
<p><script src="https://gist.github.com/joshualay/5139620.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://joshualay.net/blog/2013/03/ios-development-saving-uilabel-as-uiimage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.287 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-04-30 23:01:31 -->

<!-- Compression = gzip -->