为UITabBar设置活动图像

Jon*_*nes 3 xcode objective-c ios5

我已经以UITabBar编程方式定义了一个但是如何UITabBar在项目处于活动状态时设置自定义图标?

这是我用于声明UITabBar按钮的代码,但是如何在活动时设置自定义图像?

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {
        self.title = NSLocalizedString(@"Free", @"Free");
        self.tabBarItem.image = [UIImage imageNamed:@"Free.png"];
    }

    return self;
}
Run Code Online (Sandbox Code Playgroud)

Jer*_*Jay 7

iOS7中的新功能,现在的方法是使用以下selectedImage属性tabBarItem:

self.tabBarItem.selectedImage = [UIImage imageNamed:@"Free_Selected.png"];
Run Code Online (Sandbox Code Playgroud)