心得体会???
自定義
@interface KKTabBar : UITabBar NS_CLASS_AVAILABLE_IOS(2_0) @interface UITabBar : UIView UITabBar 繼承自 UIView所以可以在 UITabBar 上添加view啦。 - (instancetype)init {self = [super init];if (self) {UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"menu_bottom"]];imgView.size = CGSizeMake([UIScreen mainScreen].bounds.size.width, 49);[self addSubview:imgView];UIView *view = [[UIView alloc] init];view.size = CGSizeMake([UIScreen mainScreen].bounds.size.width/4, 2);view.x = 0;view.y = 0;view.backgroundColor = [UIColor whiteColor];[self addSubview:view];self.barTopView = view;}return self; }
--------------
| UITabBarController |
-------------- @interface KKTabBarController : UITabBarController@end + (void)initialize {NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];dic[NSForegroundColorAttributeName] = [UIColor purpleColor];NSMutableDictionary *selectDic = [[NSMutableDictionary alloc] init];selectDic[NSForegroundColorAttributeName] = [UIColor redColor];UITabBarItem *item = [UITabBarItem appearance];[item setTitleTextAttributes:dic forState:UIControlStateNormal];[item setTitleTextAttributes:selectDic forState:UIControlStateSelected];}- (void)viewDidLoad {[super viewDidLoad];KKTabBar *tabBar = [[KKTabBar alloc] init];tabBar.delegate = self;[self setValue:tabBar forKey:@"tabBar"];KKHomeViewController *home = [[KKHomeViewController alloc] init];[self addVc:home title:@"主頁" image:@"icon_home" selectImage:@"icon_home" tag:1];KKCollectController *collect = [[KKCollectController alloc] init];[self addVc:collect title:@"收藏" image:@"icon_fav" selectImage:@"icon_fav" tag:2];KKSearchController *search = [[KKSearchController alloc] init];[self addVc:search title:@"搜索" image:@"icon_search" selectImage:@"icon_search" tag:3];UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"moreController"]; // KKMoreController *more = [[KKMoreController alloc] init];[self addVc:vc title:@"更多" image:@"icon_more" selectImage:@"icon_more" tag:4];}- (void)addVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectImage:(NSString *)selectImage tag:(NSUInteger)tag{vc.title = title;// 放棄系統默認渲染方式,顯示圖片原本樣式 // img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];vc.tabBarItem.image = [UIImage imageNamed:image];vc.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];vc.tabBarItem.tag = tag;KKNavController *nav = [[KKNavController alloc] initWithRootViewController:vc];[self addChildViewController:nav];}
?
----------------| UINavigationController |
---------------- @interface KKNavController : UINavigationController@end @implementation KKNavController- (void)viewDidLoad {[super viewDidLoad];NSMutableDictionary *dic = [NSMutableDictionary dictionary];dic[NSForegroundColorAttributeName] = [UIColor whiteColor];UINavigationBar *item = [UINavigationBar appearance];[item setTitleTextAttributes:dic];[self.navigationBar setBackgroundImage:[UIImage imageNamed:@"top"] forBarMetrics:UIBarMetricsDefault];}- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{if (self.childViewControllers.count>0) {viewController.hidesBottomBarWhenPushed = YES;UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];[btn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];[btn setBackgroundImage:[UIImage imageNamed:@"back_hover"] forState:UIControlStateSelected];[btn setTitle:@"返回" forState:UIControlStateNormal];btn.titleLabel.font = [UIFont systemFontOfSize:15];[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];btn.size = CGSizeMake(50, 29);btn.backgroundColor = [UIColor lightGrayColor];// btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; // btn.contentEdgeInsets = UIEdgeInsetsMake(0, -50, 0, 0); [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];}[super pushViewController:viewController animated:animated];}- (void)back{[self popViewControllerAnimated:YES];}
?
轉載于:https://www.cnblogs.com/kinghx/p/5236497.html
總結
- 上一篇: AIX下RAC搭建 Oracle10G(
- 下一篇: MediaWiki使用指南