tabBar&图片渲染

#import "LYTabBarController.h"
#import "LYNewsViewController.h"
#import "LYReadingViewController.h"
#import "LYAudioVisualViewController.h"
#import "LYTopicViewController.h"
#import "LYMeViewController.h"

@interface LYTabBarController ()
@end

@implementation LYTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    NSArray *titles = @[@"新闻", @"阅读", @"视听", @"话题", @"我"];
    NSArray *vcNames = @[@"LYNewsViewController", @"LYReadingViewController", @"LYAudioVisualViewController", @"LYTopicViewController", @"LYMeViewController"];
    NSMutableArray *navCs = [NSMutableArray array];
    for (NSInteger i = 0; i < 5; i ++) {
        UIViewController *vc = [[NSClassFromString(vcNames[i]) alloc] init];
        vc.title = titles[i];
        UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:vc];
        [navCs addObject:navC];

// 图片渲染
        UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:titles[i] image:[[UIImage imageNamed:[NSString stringWithFormat:@"anchor%ld", (long)i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:[NSString stringWithFormat:@"anchor%ld", (long)(i + 5)]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        navC.tabBarItem = item;
    }

    self.tabBar.barTintColor = [UIColor grayColor];
    self.tabBar.tintColor = [UIColor grayColor];
    self.viewControllers = navCs;
}

@end

推荐阅读更多精彩内容