ios 自定义tabbar原生的tabbar怎么还出现

 我来答
kk...r@163.com
2017-10-28 · 超过27用户采纳过TA的回答
知道答主
回答量:94
采纳率:0%
帮助的人:31.9万
展开全部
#import "SZMTabBarController.h"
#import "SZMTabBar.h"
#import "SZMHomeViewCtrl.h"
#import "SZMNavigationController.h"
#import "SZMDiscoerViewCtrl.h"
@interface SZMTabBarController ()

@end

@implementation SZMTabBarController

- (void)viewDidLoad {
[super viewDidLoad];
//初始化自tabbar
SZMTabBar *tabBar = [[SZMTabBar alloc]init];
tabBar.delegate = self;
//通KVC设置读属性
[self setValue:tabBar forKey:@"tabBar"];

//添加四控制器
//首页
SZMHomeViewCtrl *homeCtrl = [[SZMHomeViewCtrl alloc]init];
[self addChildVc:homeCtrl title:@"首页" imageName:@"tabbar_home" selImgName:@"tabbar_home_selected"];

UITableViewController *messageCtrl = [[UITableViewController alloc]init];
[self addChildVc:messageCtrl title:@"消息" imageName:@"tabbar_message_center" selImgName:@"tabbar_message_center_selected"];
SZMDiscoerViewCtrl *discoveryCtrl = [[SZMDiscoerViewCtrl alloc]init];
[self addChildVc:discoveryCtrl title:@"发现" imageName:@"tabbar_discover" selImgName:@"tabbar_discover_selected"];
UITableViewController *profileCtrl = [[UITableViewController alloc]init];
[self addChildVc:profileCtrl title:@"我" imageName:@"tabbar_profile" selImgName:@"tabbar_profile_selected"];

}
//设置tabbar些属性
- (void)addChildVc:(UIViewController *)Controller title:(NSString *)title imageName:(NSString *)imgName selImgName:(NSString *)selImgName{
Controller.title = title;
Controller.tabBarItem.image = [UIImage imageNamed:imgName];
Controller.tabBarItem.selectedImage = [UIImage imageNamed:selImgName];
self.tabBar.tintColor = [UIColor orangeColor];
SZMNavigationController *navCtrl = [[SZMNavigationController alloc]initWithRootViewController:Controller];

[self addChildViewController:navCtrl];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void)TabBar:(SZMTabBar *)TabBar plusBtnDidClick:(UIButton *)btn{
NSLog(@"1");
}

@end
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式