自带TabBar选中图片设置问题

 

 

设置为UIImageRenderingModeAlwaysOriginal 

就会显示出选中状态的图片。当然普通状态的也需要设置。

 UINavigationController *nav =({

        

        UINavigationController *controller = [[UINavigationController alloc]initWithRootViewController:rootVC];

        [controller.tabBarItem setTitle:title];

        UIImage *selectImage = ({

            UIImage *image = [UIImage imageNamed:selectString];

    UIImageRenderingModeAutomatic,          // Use the default rendering mode for the context where the image is used

    UIImageRenderingModeAlwaysOriginal,     // Always draw the original image, without treating it as a template

    UIImageRenderingModeAlwaysTemplate,     // Always draw the image as a template image, ignoring its color 

            image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

            image;

        });

        [controller.tabBarItem setSelectedImage:selectImage];

        [controller.tabBarItem setImage:[UIImage imageNamed:normalString]];

        controller;

    });

posted on 2015-10-14 19:43  XHShare  阅读(319)  评论(0编辑  收藏  举报

导航