Sunday, April 24, 2011

Roaming in jamaica

£6 per MB and it's EDGE, give me strength please.

One flip side this country is a very different to the one I left. But for the most part different for the better.

Going to my grandparents house for the first time in 10 years has been fairly emotional. I'm still expecting to see them around house despite the fact the both have been dead for sometime.

I've compared it to a time machine, as it feels like I've just fast forwarded into the future. One without two people that I had come to know and love so well.

When I landed the lady at customs asked why I hadn't been back in so long (10 years), I'm slowly learning that it's because I knew subconsciously that it would be an emotional roller coaster.

Tuesday, April 12, 2011

Animating a series of images with CALayer

So you want a to animate a series of images, flip book style. While it is true you can use UIImageView, everyone knows that is for wimps. Real men (& ladies ;) ) use CALayer (like a boss)...

But how? Well you might have some how got in your head that CALayer's contents property supports a NSArray of CGImages. Well this is not the answer, remember that the contents property takes an 'id'as a argument so it supports virtually everything under the sun and then some. Hell, if you felt like making crazy things happen you could just throw a NSData object in there.

Anyways, the actual solution is to use a CAKeyFrameAnimation, to manage the rotation of your images, control the frame rate, and ultimately the duration.

Well all is said and done it should look at this

Sunday, April 10, 2011

Drawing text with a Gradient

Problem

You want to draw (unicode) text with filled with a gradient.

Solution

Since my middle name is now "Core Graphics", let me help you out. It's actually pretty simple. Create your desired gradient in a your image editor of choice, and save it as a PNG. Import it into your project and then ...

Yep folks thats it. Now if you find that your gradient is slightly out of place, you can use CGContextSetPatternPhase to help. You of course would use this before your drawing statement. The docs say:

The pattern phase is a translation that Quartz applies prior to drawing a pattern in the context. The pattern phase is part of the graphics state of a context, and the default pattern phase is (0,0). Setting the pattern phase has the effect of temporarily changing the pattern matrix of any pattern you draw. For example, setting the context’s pattern phase to (2,3) has the effect of moving the start of pattern cell tiling to the point (2,3) in default user space.

So when all is said and done you get this lovely effect

text drawn with a gradient Best of all this effect works all the back to iOS 2.0!

Saturday, April 02, 2011

Problem: Symbolicate won't ... um symbolicate.

Long live Crash reports, Crash reports are dead. We all love em right, couldn't live without them. But what happens when crash reports go bad. Sadly this isn't a lead up to a blockbuster movie but in fact a real life issue.

As much as a i love Xcode 4, (and i really love it) it swallows errors that symbolicatecrash script spits out. This caused me to send loads of time trying to fix an issue that i knew nothing about.

Well here's the solution. 

1. Do a project clean in Xcode (cmd+shift+K)
2. Delete the entire 'PROJECT/build' directory
3. Go to ~/Library/Application Support/iPhone Simulator/VERSION/Applications/UUID and delete each folder that contains your application name. Be sure to do so for each Version of the SDK.

And then attempt to symbolicate your reports.

I'm led to believe that some genius (who i'll target at WWDC and buy him/her a beer) thought it would be a great idea to use Spotlight to find dSYM files. Sadly i don't believe they thought (or could) apply any sort of search order, leading to spotlight returning random binaries. (When good ideas go wrong).

FYI. If your a member of the Xcode Team, i genuinely appreciate all the work that you folks put into 4.x.