Tag Archives: apple

Animating Interfaces with Core Animation: Part 3

6 Jan

This is the third in a series of posts I’m writing on animating iOS interfaces using Core Animation. In the first post I created a planetary orbit demo using nested CALayer objects. The second post showed how to dress up a UI by animating an image.

This time I’ll show how you can trigger animations in response to button actions to illustrate to the user that an action is taking place.

Read on to see more

(more…)

Animating Interfaces with Core Animation: Part 2

5 Jan

This is the second in a series of posts I’m writing on animating iOS interfaces using Core Animation. In the previous post I created a planetary orbit demo using nested CALayer objects.

This time I’m going to show how you can dress up a UI by creating a simple effect using an image and Core Animation.

Read on to see more

(more…)

Animating Interfaces with Core Animation: Part 1

4 Jan

One of the greatest things about the iOS platform and applications people see on it is its beauty. Smooth gradients, consistent transitions, and animations that illustrate the transition of UI elements from one state to another. Animations are more than flashy eye-candy; they tell the user what’s happening. If an element is being deleted, instead of it simply disappearing it fades or slides out of view. Unlike traditional desktop or web applications where a “2 items deleted” statusbar message is necessary, these animations are in many cases enough.

Knowing where to start with animations can be a problem for developers though, because there’s many different steps involved. Instead of walking you through it fully here in the blog, I highly recommend you watch the WWDC 2010 videos on the topic. I truly mean it; anything I do here will simply be a rehash of that material, and I don’t see the point in reproducing perfectly good documentation unnecessarily.

  • WWDC 2010 Session 123 – Building Animation Driven Interfaces
  • WWDC 2010 Session 424 – Core Animation in Practice, Part 1
  • WWDC 2010 Session 425 – Core Animation in Practice, Part 2

Read on to see more

(more…)

iOS Development Link Roundup: Part 1

25 Nov

I’ve often been asked by people about where to start with iOS programming, whether they be co-workers, colleagues in the same line of work at other companies, or even total strangers who happen to see me happily working away on my personal projects in Xcode. Some rather naïve people assume that I learned from a book, still others even think I took a class to learn all of this! I can say definitively that it’s in my opinion that to be a great iOS developer, you just need to write apps, and lots of them. Experiment, try different things out, and more importantly, buy a few really good iPad and iPhone apps so you can see for yourself the design patterns that make good apps, and those that make poor apps.

More than that however is knowing how to implement tiny techniques. It’s the tips to get you started on animations or laying out UITableViewControllers, or perhaps how to do that tiny bit of custom drawing you need. It’s also the libraries and 3rd-party modules that fill in the gaps in Apple’s SDK, such as handy progress indicator alert classes, or easy-to-use async HTTP libraries. Knowing a few key points can take you a long way toward building your first few apps, and in the process you’ll learn more than if you were to take a class.

I usually keep my bookmarks organized using Delicious.com, being one of their early adopters (back when their domain was del.icio.us). Check my iPhone tag on Delicious to see my full list of links that I found bookmark-worthy. For a more decisive list that isn’t sorted chronologically, here’s my breakdown of some of the better sites to find information on iOS mobile development. (more…)

Rendering views using CALayer, Part 1

13 Nov

For myDrumPad the main pad buttons are images. I create a UIButton object, and use setBackgroundImage:forState: to customize which image will be used for each state (UIControlStateNormal and UIControlStateHighlighted mainly).  I customize the title label font, shadow and color, and voilà I have a pad button that simulates the look and feel of  a Korg padKONTROL. There’s just a few small problems with it.

  1. The images on the iPad are fairly large, and memory is at a premium.
  2. The size of these buttons can change in portrait vs. landscape. It’s time-consuming to export different versions from Photoshop for the different orientations.
  3. The buttons are sized differently depending on the size of the button grid (e.g. a 3×3 grid of buttons have larger images than 4×4 or 5×5 grids). If I resize these images on-the-fly, then the edges look blurred and aren’t well-defined.
  4. The retina display complicates all of this, meaning I have to have two versions of each image.
  5. I want to be able to customize the buttons to have different colors when you’re on different drum sets.

Because of that long list, simply using an image isn’t good enough. But instead of drawing my images using regular Core Graphics drawing routines, I’m going to use Core Animation Layers, or CALayers, to accomplish the same thing. Ultimately I want my buttons to be able to be animated, to change color, and to feel more “alive” than a static image could accomplish. (more…)

Revenue Canada wants me to buy an iMac 27″

10 Nov

For as long as I’ve been a developer, there was only ever once when I had a machine that I felt was an adequate development workstation. That was around 2001 when I had a dual-proc 667MHz P3 768MB RAM and three 17″ CRT monitors. This baby put out enough heat that my home-office didn’t need a heater on during the rainy Seattle winters; in fact, it was so warm in there that I’d wear shorts, a tee-shirt, and left the window wide open.

Since that time though, my computer has typically been limited to a laptop, my biggest since that dual-proc furnace being a 17″ Powerbook G4. Being a developer, there are three priorities that stand out above all others: screen real-estate, memory and CPU speed. Due to my history of being a web developer, only the first item on that list was a big priority. Since becoming an iOS developer, where your productivity is directly related to how fast you can compile your app, and how fast your performance profiling tools can run, I’ve encountered the other barriers developers face.

In the past though, I’ve largely been a cheap developer, opting to get by with what I have, or doing whatever I can to improve my productivity in other areas. However, for the first time since that space-heater with a RAID array, I have an opportunity to get the workstation I’ve been dreaming of.

Since I run my own personal business on the side, I can take advantage of tax deductions that normally wouldn’t be available to me. Computer purchases, like other capital expenditures, can be tax deductible, so the money I would have to pay the Government in the form of taxes, can be deducted from what I owe them. Normally only a certain percentage of that purchase price can be written off per year, in a process called amortization, so it’s effects are only moderately felt.

In Canada, as part of their economic stimulus package they put together to boost small business spending, they instituted a limited-time Capital Cost Allowance for 100% tax deductions on computer hardware and software purchases made between January 27th 2009 and February 1st 2011.

Think of it this way: assume I had a decent year of app sales on the iTunes App Store, and because of my extra income, let’s say I owe the Government $10,000 in taxes. Normally my only recourse is to dig up $10k (which, since I’m a good little business owner, has been sitting in a savings account all year long) and hand it over to Revenue Canada.

But because of this stimulus package, I have an option. I can instead buy $4,000 worth of computer hardware necessary to effectively run my business, and then only give $6,000 to the Government. No need to spread that deduction out over several years, no need to have the accounting hassle of carrying that equipment value over year after year. I see, I buy, I save.

There are limitations of course. Just as with other business deductions, you can’t cheat and take advantage of the system for your own profit. At home I use the equipment in support of my iOS development, web development, and any testing I need to do.

So what do I get for my last year?

This is the last year you can take advantage of this deduction, which really is a shame. But now that my side work is taking me to more and more demanding areas, such as Core Audio, OpenGL, and a little bit of video work, I feel that now is the time to invest in that dream machine I’ve always wanted and needed.

The question is, what’ll it be? Do I add on a cinema display to my laptop? Do I get a fully pimped-out quad-core iMac 27″? Or do I splurge and get both?  Based on my preliminary estimates for how much I’ll be owing in taxes, here’s my shopping list:

I’m probably going to wait until mid-December, or perhaps in January when I get back from my various weeks of travel.  What are your thoughts?  And if you’re a Canadian iOS business owner, what are you going to do to take advantage of the capital cost allowance?

Recovering from bit rot

9 Nov

One of the things that’s hard as a developer is keeping your legacy code up to date.  It’s all too easy to fire-and-forget; write your code, debug it just enough so that it compiles, and then forget it until it breaks again.  I’m guilty of that as well.  In fact, just today I discovered that my continuous deployment configuration for Boomle was broken…for the past 3 months.

After merging my code from a private repo over to Github, it still didn’t work.  After updating the Hudson build configuration to point at the proper repos and to respond to the proper webhooks (to get automatically triggered on a new check-in), it STILL didn’t work.  You see, not only does configuration change, but SDKs and APIs shift out from under you.  The iOS SDK had changed out from under my project, and the Xcode configuration was pointing at libraries and SDKs that no longer were shipped by Apple.

The lesson for me here is this: I need to get off my ass every few weeks to at least look at my source code.  Kick the tires a little, hit a build every now and then, and check that everything is still okay.  Because the longer you wait, the more things can fall apart.  Each one of those issues I mentioned above would have been simple to fix, had I addressed them right away.  But the more problems that build up, the more difficult it is to clean up your code.

As it is, I still need to integrate Game Center with Boomle, and refactor its drawing routines to be more efficient.

Now, I don’t believe in New Year’s resolutions.  Instead, I believe in making resolutions whenever they’re relevant, and sticking to them without the excuse of a New Year to motivate you.  My resolution is to take care of my projects proactively, instead of forgetting them.  Treat it like the quasi-living thing that I’m anthropomorphizing it to be, because even inactive projects need love too.

Showing Apple my app via Facebook

3 Nov

I’ve been working recently on getting more exposure to my existing apps, especially myDrumPad.  It’s a fun app, and I have a few more updates that are in the works when I get a couple of free weekends, but frankly I’d like to see its sales figures climb a bit higher than they are now.  Of course, if you’re an iOS developer, you’ll know the biggest thing that can improve your sales rankings is to be featured on the AppStore.  A large part of getting featured is left up to lucky chance, but to improve your odds, one of the things you can do is to target Apple employees with Facebook ads of your application.  Read on to see the results I’ve had so far.

(more…)

Building a custom Dashboard-like UIButton

19 Sep

Help overlay showing the Parking Mobility quick start help

As part of the Parking Mobility iPhone app I’ve been building, I wanted to integrate a simple “Quick Start” help guide to show people how to use the app without being intrusive.  I wanted to use the project’s branding as much as possible, and give the user a feeling like they haven’t left the main portion of the app.  So I wanted the user to be comfortable with it, and always have a quick way to close the help window to get back to the app.

In the end I created a little Close button in the top-left corner to mimic the behaviour of the Mac OS X Dashboard widgets.  But I didn’t want to simply add a static image since those don’t scale easily.  Plus I wanted to learn more about native drawing using Core Animation and Quartz2D.

The end result is actually really simple.  I subclassed the UIButton class, and overrode the drawRect: method to use some native drawing primitives.


Reading through the source code, you can see how I split the drawing between two different routines.  First, my layer drawing which draws the border, the circle, shadows, etc is handled using raw CALayer drawing.  The second block, inside drawRect:, draws the lines forming the “X” inside.

Simply add these files to your project, and create a new DNCloseButton object and add it to your view.

If you find any bugs in this code, please let me know and I’ll update this post.  I hope this works out as well for you as it has for me.

Dealing with MKMapView’s Google logo with translucent toolbars

12 Sep

One of the iPhone applications I’ve written, Parking Mobility, is primarily a map-based application.  Since the iPhone’s screen is so small, we want to maximize the screen real-estate while still providing navigation bars for users to interact with.  To that end, the app uses a black-translucent navbar and toolbar at the top and bottom of the screen.  In the past this has never been a problem, and most mapping applications do the same thing.  I recently submitted a huge update to the app which is a complete re-write as a 100% native Objective-C based application (all vestiges of PhoneGap having been removed).  With this latest submission though, we’ve run into problems.

Read on for more, and what I’ve done to (hopefully) get around this.

(more…)