// LYTabBarController.m
// Created by younglee on **/**/**
// Copyright (c) **** younglee. All rights reserved.
#import "LYTabBarController.h"
#import "LYFirstViewController.h"
#import "LYSecondViewController.h"
#import "LYThirdViewController.h"
#import "LYFourthViewController.h"
@implementation LYTabBarController
- (void)initialize {
NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
normalAttrs[NSFontArrtibuteName] = [UIFont systemFontOfSize:12];
normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selecteddAttrs[NSFontAttributeName] = [NSFont systemFontOfSize:12];
selectedAttrs[NSForegroundAttributeName] = [UIColor darkGrayColor];
[[UIAppearance appearance] setAttributes:normalAttrs forState:UIControlStateNormal];
[[UIAppearance appearance] setAttributes:selectedAttrs forState:UIControlStateSelected];
}
- (void) viewDidLoad {
[super viewDidLoad];
[self setupChildVc:[LYFirstViewController class] withTitle:@"item01" imageNamed:@"image01" selectedImageNamed:@"selectedImage01"];
[self setupChildVc:[LYSecondViewController class] withTitle:@"item02" imageNamed:@"image02" selectedImageNamed:@"selectedImage02"];
[self setupChildVc:[LYThirdViewController class] withTitle:@"item03" imageNamed:@"image03" selectedImageNamed:@"selectedImage03"];
[self setupChildVc:[LYFourthViewController class] withTitle:@"item04" imageNamed:@"image04" selectedImageNamed:@"selectedImage04"];
}
- (void)setupChildVc:(Class)class withTitle:(NSString *)title imageNamed:(NSString *)imageName selectedImageNamed:(NSString *)selectedImageName {
UIViewController *vc = [[class alloc] init];
vc.tabBarItem.title = title;
vc.tabBarItem.image = [UIImage imagedNamed:imageName];
vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
vc.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(100)/100.0 green:arc4random_uniform(100)/100.0 blue:arc4random_uniform(100)/100.0 alpha:1.0];
[self addChildViewController:[[UINavigationController alloc] initWithRootViewController:vc]];
}
@end
第一天04-自定义子控制器
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
- 不管是安卓的官方文档还是源码注释,处处可见“从 Activity A 跳到 Activity B,当系统内存不足时...