美文网首页
tabBar&图片渲染

tabBar&图片渲染

作者: March_Cullen | 来源:发表于2017-03-02 21:11 被阅读0次
#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

相关文章

网友评论

      本文标题:tabBar&图片渲染

      本文链接:https://www.haomeiwen.com/subject/cyikgttx.html