一.刪除系統(tǒng)的標(biāo)簽欄上的按鈕(tabbarItem)
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),懷柔網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:懷柔等地區(qū)。懷柔做網(wǎng)站價(jià)格咨詢:18980820575//設(shè)置tabbar的背景
[self.tabBar setBackgroundImage:[UIImage p_w_picpathNamed:@"tab_bg_all.png"]];
//刪除系統(tǒng)的tabbarItem
NSArray *array = self.tabBar.subviews;
//注意:UITabBarButton是一個(gè)私有的API,沒(méi)有公開(kāi)出來(lái)
//遍歷tabbar中所有的子視圖,并且移除tabbarItem
for (UIView *view in array) {
Class cls = NSClassFromString(@"UITabBarButton");
if ([view isKindOfClass: cls]) {
//移除tabbar上的按鈕
[view removeFromSuperview];
}
}
//創(chuàng)建自己的圖片
//創(chuàng)建選擇視圖
_selectedImgView = [[UIImageView alloc] initWithImage:[UIImage p_w_picpathNamed:@"selectTabbar_bg_all1"]];
_selectedImgView.frame = CGRectMake(0, 0, 49, 49);
[self.tabBar addSubview:_selectedImgView];
//創(chuàng)建按鈕
NSArray *imgArr = @[@"movie_home.png",
@"msg_new.png",
@"start_top250.png",
@"icon_cinema.png",
@"more_setting.png"];
NSArray *titleArrray = @[@"電影", @"新聞", @"top", @"影院", @"更多"];
CGFloat width = kScreenWidth / imgArr.count;
CGFloat height = self.tabBar.height;
for (int i = 0; i < imgArr.count; i++) {
NSString *imgName = imgArr[i];
NSString *title = titleArrray[i];
MainTabbarItem *item = [[MainTabbarItem alloc] initWithFrame:CGRectMake(width * i, 0, width, height)
p_w_picpathName:imgName
title:title];
item.tag = 2015 + i;
[item addTarget:self action:@selector(clickItem:) forControlEvents:UIControlEventTouchUpInside];
[self.tabBar addSubview:item];
if (i == 0) {
_selectedImgView.center = item.center;
}
當(dāng)push到二級(jí)界面時(shí),隱藏標(biāo)簽欄
在自定義初始化方法中
self.hidesBottomBarWhenPushed = YES;
二,情況二,隱藏系統(tǒng)的標(biāo)簽欄,自定義標(biāo)簽欄
self.tabBar.hidden = YES;
_taBarView = [[UIImageView alloc]initWithFrame:CGRectMake(0, kScreenHeight-55, kScreenWidth, 55)];
當(dāng)push到二級(jí)界面時(shí),隱藏標(biāo)簽欄
#pragma mark - UINavigationControllerDelegate
//進(jìn)入到二級(jí)界面以后隱藏標(biāo)簽欄(自定義的)
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
//獲取標(biāo)簽欄
MainTabBarViewController *mainBar = (MainTabBarViewController *)self.tabBarController;
//當(dāng)前控制器的個(gè)數(shù)
NSInteger count = self.viewControllers.count;
if (count == 1) {
//顯示標(biāo)簽欄
[UIView animateWithDuration:0.2 animations:^{
mainBar.taBarView.right = kScreenWidth;
}];
}else if (count == 2){
[UIView animateWithDuration:0.2 animations:^{
mainBar.taBarView.right = 0;
}];
}
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。