自定义UITabBarItem在ios8显示异常

升级到xcode6后,自定义的UITabBarItem在ios8里图标变成灰色,点击后变成蓝色,原因使用了在已经被废弃的方法

- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage NS_DEPRECATED_IOS(5_0,7_0,"Use initWithTitle:image:selectedImage: or the image and selectedImage properties along with UIImageRenderingModeAlwaysOriginal");

解决办法

//创建自定义UITabBarItem
- (UITabBarItem *) createTabBarItem:(NSString *)strTitle normalImage:(NSString *)strNormalImg selectedImage:(NSString *)strSelectedImg itemTag:(NSInteger)intTag
{
    UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:strTitle image:nil tag:intTag];
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:172/255.0 green:172/255.0 blue:172/255.0 alpha:1.0], UITextAttributeTextColor, nil]
                        forState:UIControlStateNormal];
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:53/255.0 green:0.0 blue:0.0 alpha:1.0], UITextAttributeTextColor, nil] forState:UIControlStateSelected];
    [item setTitlePositionAdjustment:UIOffsetMake(item.titlePositionAdjustment.horizontal,item.titlePositionAdjustment.vertical-5.0)];
    if (isIOS7) {
        [item setImage:[[UIImage imageNamed:strNormalImg] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        [item setSelectedImage:[[UIImage imageNamed:strSelectedImg] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    }else{
        [item setFinishedSelectedImage:[UIImage imageNamed:strSelectedImg]
           withFinishedUnselectedImage:[UIImage imageNamed:strNormalImg]];
    }
    return item;
}