<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                @有的時候,我們不想用系統提供的UITabBarController,這個時候就需要自定義了,還能實現一定的動畫效果,比如仿新浪的,切換標簽,會有圖片隨著移動 @自定義的時候,一般是用UIImageView+UIButton實現 ~~~ #pragma mark - 自定義TarBar - (void)createCustomTarBar{ #pragma mark 初始化TarBar背景 UIImageView * tarbarBackground = [[UIImageView alloc]initWithFrame:CGRectMake(0, ScreenHeight-49, ScreenWidth, 49)]; tarbarBackground.image = [UIImage imageNamed:@"tarBarBackground"]; // 切記,不能漏了這句話,UIImageView會阻擋程序檢測到點擊在button上 tarbarBackground.userInteractionEnabled = YES; [self.view addSubview:tarbarBackground]; [tarbarBackground release]; #pragma mark 初始化選中時的圖片 _selectImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"select"]]; _selectImageView.frame = CGRectMake(5, 4, 54, 42); // 思考為什么,這里不需要開交互,點擊button也能響應 //selectImageView.userInteractionEnabled = NO; [tarbarBackground addSubview:_selectImageView]; [_selectImageView release]; #pragma mark 初始化tabBarItem----->UIButton NSArray * defaultBackground = @[@"tabbar_home",@"tabbar_message_center",@"tabbar_profile",@"tabbar_discover",@"tabbar_more"]; for (int i = 0; i < 5; i++) { // button與tarbarBackground 是上下的層級關系 UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(10+64*i, 5, 44, 41); button.tag = TAG + i; [button setImage:[UIImage imageNamed:[defaultBackground objectAtIndex:i]] forState:UIControlStateNormal]; [button addTarget:self action:@selector(onClickChangeView:) forControlEvents:UIControlEventTouchUpInside]; [tarbarBackground addSubview:button]; } } - (void)onClickChangeView:(UIButton *)button{ self.selectedIndex = button.tag; // block設定動畫 [UIView animateWithDuration:0.5 animations:^{ _selectImageView.frame = CGRectMake(5 + button.tag * 64, 4, 54, 42); }]; } ~~~ ~~~ #pragma mark - 初始化ViewController - (void)createTarBarViewController{ #pragma mark 第一個視圖ViewController HMT_AViewController * tabBarViewA = [[HMT_AViewController alloc] init]; // 設置A視圖下----標簽欄標題文字(可參照微信或者QQ體會) //tabBarViewA.tabBarItem.title = @"微信"; // 設置A視圖下----標簽欄圖片(因為自己沒有圖片,在這里隨便設置了個名字) //tabBarViewA.tabBarItem.image = [UIImage imageNamed:@"1.png"]; // 設置A視圖下----標簽欄信息提示(住:badgeValue是NSString類型 如下設置了3,就像QQ消息有3條未接受一樣,給人一種提醒) //tabBarViewA.tabBarItem.badgeValue = @"3"; UINavigationController * tabBarViewNA = [[UINavigationController alloc]initWithRootViewController:tabBarViewA]; // ios7棄用了----標簽欄選中的時候顯示一張圖片,沒選中的時候顯示另一張圖片 //[tabBarViewA.tabBarItem setFinishedSelectedImage:actionMenu.selectedIcon withFinishedUnselectedImage:actionMenu.icon]; // ios7的方法(自己沒有圖片,所以代碼里面的圖片都是一個隨便取的名字,沒有實用意義) //tabBarViewA.tabBarItem.selectedImage = actionMenu.selectedIcon; #pragma mark 第二個視圖ViewController // 第二個視圖ViewController HMT_BViewController * tabBarViewB = [[HMT_BViewController alloc] init]; // 設置B視圖下----標簽欄 // 用系統提供的標識(可以算等價于圖標和文字)進行設置(參數:UITabBarSystemItem是個枚舉值,想要什么形式,就去系統提供的API中找) //tabBarViewB.tabBarItem = [[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1]autorelease]; // 設置B視圖下----標簽欄信息提示 //tabBarViewB.tabBarItem.badgeValue = @"GO"; #pragma mark 第三個視圖ViewController HMT_CViewController * tabBarViewC = [[HMT_CViewController alloc] init]; // ViewController -- NavigationController -- UITabBarController 3者想相結合 UINavigationController * tabBarViewNC = [[UINavigationController alloc]initWithRootViewController:tabBarViewC]; tabBarViewC.tabBarItem = [[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2]autorelease]; // 設置B視圖下----標簽欄信息提示 //tabBarViewC.tabBarItem.badgeValue = @"new"; #pragma mark 第四個視圖ViewController HMT_DViewController * tabBarViewD = [[HMT_DViewController alloc] init]; //tabBarViewD.tabBarItem = [[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3]autorelease]; // 設置B視圖下----標簽欄信息提示 //tabBarViewD.tabBarItem.badgeValue = @"99"; #pragma mark 第五個視圖ViewController HMT_EViewController * tabBarViewE = [[HMT_EViewController alloc] init]; //tabBarViewE.tabBarItem = [[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:4]autorelease]; // 設置B視圖下----標簽欄信息提示 //tabBarViewE.tabBarItem.badgeValue = @"sky"; #pragma mark 第六個視圖ViewController(系統默認能顯示的最大視圖個數是5個) /* 如果你的viewControllers屬性添加了多于五個的items,那tab bar controller將會自動插入一個特殊的view controller, 稱為 More view controller,該 controller 將會負責管理多于的items,這個More view controller提供一個自定義的界面, 用table的方式呈現多余的view controller,并且view controller的數量是不限制的*/ HMT_FViewController * tabBarViewF = [[HMT_FViewController alloc] init]; //tabBarViewF.tabBarItem = [[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:5]autorelease]; // 設置F視圖下----標簽欄信息提示 //tabBarViewF.tabBarItem.badgeValue = @"AG"; #pragma mark 設置TabBarController // 創建TabBarController //UITabBarController * tabBarController = [[UITabBarController alloc]init]; // TabBarController默認是放在最底部的,如果你想調整位置,可以進行下面2部操作(44是iPhone中TabBarController和UINavigationController標準高度) //CGRect frame = CGRectMake(0, 20, 320, 44); //tabBarController.tabBar.frame = frame; // 每一個tab都必須有一個content view controller------->viewControllers屬性,用來存入一個應用的TabBarController有多少個界面切換 self.viewControllers = [NSArray arrayWithObjects:tabBarViewNA,tabBarViewB,tabBarViewNC,tabBarViewD,tabBarViewE,nil]; // 設置著色 self.tabBar.tintColor = [UIColor greenColor]; // 設置選中圖片時候 self.tabBar.selectedImageTintColor = [UIColor redColor]; // 設置背景圖片(自己沒有圖片,不進行設置) //tabBarController.tabBar.backgroundImage = [UIImage imageNamed:@"@@@@@"]; // 設置程序啟動時默認的ViewController視圖(設置為3,一共5個ViewController,進來時候顯示的視圖就是第4個-tabBarViewD,下標從0開始) //self.selectedIndex = 0; // 設置代理 self.delegate = self; //UINavigationController *nav = tabBarController.moreNavigationController; //[nav setNavigationBarHidden:YES animated:YES]; [tabBarViewA release]; [tabBarViewNA release]; [tabBarViewB release]; [tabBarViewC release]; [tabBarViewNC release]; [tabBarViewD release]; [tabBarViewE release]; [tabBarViewF release]; } // 控制哪些ViewController的標簽欄能被點擊 - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ // 代表HMT_CViewController這個View無法顯示,無法點擊到它代表的標簽欄 /*if ([viewController isKindOfClass:[HMT_CViewController class]]) { return NO; }*/ return YES; } // 選中哪個標簽欄,一個監控作用吧 - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{ NSLOG_FUNCTION; } // More view controller 將要開始編輯 - (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers{ NSLOG_FUNCTION; } // More view controller 將要結束編輯 - (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed{ NSLOG_FUNCTION; } // More view controller 編輯 - (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed{ NSLOG_FUNCTION; } ~~~ ![](https://box.kancloud.cn/2016-01-12_5694d753c8211.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看