— Category: Tutorials —

UIKit: What’s new in iOS5

In this tutorial we will use RGB() function. You need to define it in your header file. Add this line at the top of your file:

#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]

1. UISwitch

In iOS 5 you can simply tint your UISwitch control. To do that, you can use onTintColor property. In this example we will create a green UISwitch.

// sw is your UISwitch instance
sw.onTintColor = RGB(13, 165, 11);
[self.view addSubview:sw];

You can even create a image tint by using -[UIColor colorWithPatternImage:] method.

2. UITabBar

New version of iOS (finally) allows you to tint your tab bar and change color of selected item. Here’s the code for creating a dark-green tab bar with light-green selection:

// tb is your UITabBar instance
tb.tintColor = RGB(6, 71, 5);
tb.selectedImageTintColor = RGB(213, 239, 145);

3. UIProgressView & UIActivityIndicatorView

One of the new features of iOS 5 is allows you to customize your progress bars and spinners. To create a green UIProgressView, simply change it’s tint colors:

// pb is your UIProgressView instance
pv.progressTintColor = RGB(6, 71, 5);
pv.trackTintColor = RGB(213, 239, 145);

To create a blue UIActivityIndicatorView, you have to change the color property:

// aiv is your UIActivityIndicatorView instance
aiv.color = [UIColor blueColor];

There is also a new -[UIProgressView setProgress:animated:] method, which allows you to animate progress bar’s progress.


Today I present you my recent work – KSAvatarCell. This is a UITableViewCell subclass and it allows you to create a Contacts.app-like cell, where you can see image, name and description. I use it in my new project :) You can download this script on the bottom of the post but I recommend you to read the tutorial. So, let’s start!

Read more »