Tag Archives: iphone

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…)

Fun shadow effects using custom CALayer shadowPaths

16 Nov

Shadowed view using a rectangular shadowPath

I recently had to improve the performance of a few views that utilized CALayer-based shadows on rounded-rect UIView objects. On this particular iPad application, when the device was rotated, the views rotated quite a lot slower than we would have hoped. It wasn’t a show-stopper, but the jerky rotation animation made it look cheap and unpolished. The easiest way to have our cake, and eat it too, was to set a custom CGPath to the layer’s shadowPath property. This told UIKit to set the inside of the path to opaque, reducing the amount of work the rendering engine needed to perform.

// Add background tile
UIImage *bgImage = [UIImage imageNamed:@"embedded_bg.png"];
self.view.backgroundColor = [UIColor colorWithPatternImage:bgImage];
// Add the reference view
UIImage *image = [UIImage imageNamed:@"dccp.jpeg"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imgView];
imgView.center = self.view.center;
imgView.layer.shadowColor = [UIColor blackColor].CGColor;
imgView.layer.shadowOpacity = 0.7f;
imgView.layer.shadowOffset = CGSizeMake(10.0f, 10.0f);
imgView.layer.shadowRadius = 5.0f;
imgView.layer.masksToBounds = NO;
UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds];
imgView.layer.shadowPath = path.CGPath;
[imgView release];

The resulting image, as you can see above, has a shadow as you’d expect. But since we’ve declared the shape the path will have, the iPad can drastically improve its rendering performance.

Through that process however, I decided to see what sort of effects I could pull off by passing in a path other than the default rectangular bounds of the layer. Since you can create any sort of path you want, I considered the different effects I could get away with by making non-rectangular paths and using them as shadows. (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…)

Even geeks forget their passwords

13 Nov

Passwords are definitely fickle beasts.  I’m used to juggling a multitude of different semi-incomprehensible passwords containing a mixture of numbers, symbols, upper and lower-case letters, and in some cases unicode characters (letters such as ü, • and §). And for some mysterious reason I’m able to remember these gibberish-filled passwords with ease. But despite all this, when asked to input a 4-digit passcode into my iPhone to be able to lock my phone (a requirement for hooking it up to my company Exchange server), I couldn’t keep that simple password in my head for longer than 8 minutes.

Can you believe that? Numeric passwords are perhaps the easiest passwords to crack. There isn’t enough variance in the values each character can hold to guarantee uniqueness or complexity to be considered secure, yet for some reason bank ATMs and cellphones use them with impunity. Perhaps my problem is I’m so used to being security-minded, that something as simple as 1234 didn’t occur to me.

So now I’m waiting for my iPhone to restore so I can recover my device (luckily I’d backed up just prior to adding my Exchange email account).  But once I finish with this, I’ll have to do the same thing for my iPad with its 12 gigs of WWDC videos; I’m not looking forward to that.

Update: After wiping and restoring my phone from backups I was able to get at the phone without a lock code. Success! Once I checked my Exchange email again, it required me to specify a new pin code. I made sure to type something in that was really easy to remember. Something with a couple 1′s and a 5 or something. I’m not quite sure because after going upstairs for dinner, I came back downstairs and discovered I could no longer remember my new password. I’m restoring from backups yet again, and hopefully this time I can come up with a password I can remember longer than a goldfish can remember a password.

Boomle, the underdog of my iOS apps

12 Nov

Boomle is by far the lowest-selling app I have published on the iTunes App Store, and sadly as a result I just haven’t had the motivation to dedicate more time to it. However it’s times that I see people using it in person that I see just how much people enjoy playing it. I really hope I’ll have time to revisit it, because it’s one of those games that people just “get”, and is enjoyably challenging throughout the whole game.

Most anyone reading my blog won’t know what the game is, so let me explain a little.  Boomle is a relaxing game featuring balls bouncing around the screen.  They move slowly and peacefully, but if you tap anywhere on the screen you set of a small explosion.  If it encounters any of the floating balls, the ball it comes in contact with will explode as well.  This causes a chain reaction, detonating any other balls in their path.

The goal of the game is to eliminate a minimum number of balls per level, but extra points are awarded if additional balls over the minimum requirement are exploded.  And when each ball explodes, it makes a chiming musical sound.

Most people using the game for the first time will:

  1. Instinctually tap in the center of the screen;
  2. Try to tap directly on a ball, instead of in empty space (but in a place where a ball will travel to);
  3. Try to tap more than once to set off more explosions per level (which isn’t permitted).

My hope is that I can improve on the game to take advantage of the default actions people find most familiar or intuitive.  For instance, add a better scoring system that can keep track of your score over time.  When you have enough of a score you can get a second “bomb” to blow up in your level.  Each new level will give you a new bomb to detonate, but if you do well, you can acquire more bombs that you can use up on some pesky levels.

Another thing I’d like to add is an initial “Tutorial” level that has some text overlays to show how to play the game.  And to make the game more challenging, and to allow for more than the current 11 levels, I’d also like to add obstacles to make the bounce pattern of the balls inconsistent, or special balls that you should avoid detonating.

Unfortunately because of the way the game is built there are a few minor bugs, but more importantly the way the code is written makes it difficult for minor refactors.  In fact, I’m fairly certain the game will need a complete overhaul or maybe even rewrite in order to improve upon it.

In light of my limited time to work on my personal projects, as well as the aggressive roadmap I have for myDrumPad, I doubt whether I’ll have any time in the next few months to work on Boomle. Normally I’d just chalk a project like this up as a failure (the app itself works, but failed to net any large amount of sales) but since the game is so fun, and everyone I see actively playing the game absolutely enjoys it, it makes me feel guilty for leaving it behind in the dust.

If people were to discover the app and give it a try, I’m sure it would do a heck of a lot better. But due to the app’s poor visuals on the app store, it’s not something most people would try out just for the heck of it. Game Center support might help, as well as a way to share goals and achievements with friends on other places such as Twitter, etc. Beyond that, it seems like the mobile gaming space is just too noisy for a quiet and unassuming game like Boomle to be able to compete.

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.

Localizing iOS apps using ICanLocalize.com

8 Nov

As with most things, the amount of work we as developers see when starting an iOS application is just the tip of the iceberg. There’s artwork, “About” screens, tutorial pages, icons, the app’s website, and all the marketing the app needs to get it out there. Even writing the app’s description or taking screenshots for the App Store is a time-consuming process. So anything I can do to cut down on the time needed to release my app, the better I am. Therefore when I decided to have myDrumPad translated to other languages to widen my user-base, I wanted to do make it as painless as possible.

I tried tried to have friends and family who understood foreign languages help with translations, and while they were very well intentioned it really didn’t work out in the end.  What I discovered was that there really is no substitute for hiring a trained professional.  But luckily it doesn’t have to be outrageously expensive. Read on for more.

(more…)