麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

RDVTabBarController--可自由定制的iOS底部導(dǎo)航控件

2019-11-14 18:11:18
字體:
供稿:網(wǎng)友
  • RDVTabBarController:一個十分完善的tabBarController,可以自定義角標個數(shù),爽的停不下來。
  • RDVTabBarController地址:RDVTabBarController
  • Demo地址:歡迎Star

說明

  • 此教程是旨在讓你快速入手,如需更加深層次的了解,請直接RDVTabBarController地址分析即可;

使用

pod 'RDVTabBarController'

建議直接CocoaPods管理,對CocoaPods有興趣的童鞋可以戳cocoapods-install-usage

結(jié)構(gòu)

RDVTabBar @interface RDVTabBar : UIView
RDVTabBarController@interface RDVTabBarController : UIViewController 
RDVTabBarItem@interface RDVTabBarItem : UIControl

RDVTabBarController Example Usage其實已經(jīng)很詳細了,接下來看初始化

 //VString宏定義,為了就是更好的國際化語言,適配多語言,剛好此Demo也國際化了,可以參看https://github.com/sauchye/dev_notes/issues/4 #define VString(x)      NSLocalizedString(x, nil)
- (void)setupViewControllers{    SYFirstViewController *firstVC = [[SYFirstViewController alloc] init];    SYSecondViewController *secondVC = [[SYSecondViewController alloc] init];    SYThirdViewController *thirdVC = [[SYThirdViewController alloc] init];    firstVC.title = VString(@"Home");    secondVC.title = VString(@"Found");    thirdVC.title = VString(@"Me");    self.firstNav = [[SYBaseNavigationController alloc] initWithRootViewController:firstVC];    self.secondNav = [[SYBaseNavigationController alloc] initWithRootViewController:secondVC];    self.thirdNav = [[SYBaseNavigationController alloc] initWithRootViewController:thirdVC];    [self setViewControllers:@[self.firstNav, self.secondNav, self.thirdNav]];    [self customizeTabBarForController];}
- (void)customizeTabBarForController{    //tabbar 背景圖片 tabbar_background    UIImage *backgroundImage = [UIImage imageNamed:@"tabbar_background"];    //選項卡圖片    NSArray *tabBarItemImages;  	//這里添加tabBar icon圖片    //= @[VString(@"First"), VString(@"Second"),VString(@"Third")];    NSArray *tabBarItemTitles = @[VString(@"Home"), VString(@"Found"), VString(@"Me")];    NSInteger index = 0;    for (RDVTabBarItem *item in [[self tabBar] items])    {        item.titlePositionAdjustment = UIOffsetMake(0, 2.0);        [item setBackgroundSelectedImage:backgroundImage withUnselectedImage:backgroundImage];        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",[tabBarItemImages objectAtIndex:index]]];        UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",[tabBarItemImages objectAtIndex:index]]];        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];        [item setTitle:[tabBarItemTitles objectAtIndex:index]];        item.selectedTitleAttributes = @{                                         NSFontAttributeName: [UIFont boldSystemFontOfSize:12],                                         NSForegroundColorAttributeName:kNAVIGATION_BAR_COLOR,                                         };        item.unselectedTitleAttributes = @{                                           NSFontAttributeName: [UIFont boldSystemFontOfSize:12],                                           NSForegroundColorAttributeName:RGB(217, 217, 217),                                           };        [item setTitle:[tabBarItemTitles objectAtIndex:index]];        index++;    }}

這樣你的tabBar基本搭建好了,但是還需要完善一些,比如,角標設(shè)置,push隱藏等。

  • Push隱藏tabBar,你只需要這樣即可

objective-c - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[self rdv_tabBarController] setTabBarHidden:YES animated:YES]; }

  • 設(shè)置角標數(shù)

objective-c [[self rdv_tabBarItem] setBadgeValue:@"3"];

  • RDVTabBarControllerDelegate,相信你看就會明白,好的方法命名很重要啊~

``` objective-c
/**

  • Asks the delegate whether the specified view controller should be made active.
    */
  • (BOOL)tabBarController:(RDVTabBarController )tabBarController shouldSelectViewController:(UIViewController )viewController;

/**

  • Tells the delegate that the user selected an item in the tab bar.
    */
  • (void)tabBarController:(RDVTabBarController )tabBarController didSelectViewController:(UIViewController )viewController;
    ```

  • 還有需要多等待你去發(fā)現(xiàn)...


結(jié)語

RDVTabBarController是一個很棒的第三方tabBarController,值得我們學(xué)習(xí)和思考。

  • 相比傳統(tǒng)第三方,你會發(fā)現(xiàn)可以很好的定制角標,這是極好的,當然你也可以自定義;
  • 但是不能定義中間凸起的tabBar,好早之前去哪兒就是中間凸起一個tabBar,不過現(xiàn)在去哪兒也改成傳統(tǒng)的tabBar了;

--

本文,由我們 iOS122 的小伙伴 @Sauchye?供稿,更多討論,參見: http://www.ios122.com/tag/rdvtabbarcontroller/


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 精品一区二区在线观看视频 | 日本中文高清 | 双性帝王调教跪撅打屁股 | 亚洲一级片在线观看 | 91国内精品久久久久免费影院 | 羞羞视频2023| 亚洲免费视频大全 | 免费在线观看成年人视频 | 国产一区二区精品免费 | 久久精品无码一区二区三区 | 免费三级大片 | 一本大道av| 黄污视频在线看 | 国产一区二区在线免费观看 | 国产女王女m视频vk 中文日韩 | 久久久久久久久久综合 | 91精品国产免费久久 | 久久精品视频12 | 九九热精品视频在线 | a网站在线 | 国内精品国产三级国产a久久 | jizzyouxxxx| 色吧久久| 老师你怎么会在这第2季出现 | 免费男女乱淫真视频 | 亚洲国产精品500在线观看 | 精品在线免费播放 | 亚洲电影在线观看高清免费 | 哪里可以看免费的av | 国产高潮国产高潮久久久91 | 国产精品成人一区二区三区电影毛片 | 黄色免费在线视频网站 | 毛片在线看免费 | 精品一区二区三区在线观看国产 | 国产午夜精品一区二区三区免费 | 视频国产一区二区 | 国产精品欧美久久久久一区二区 | 国产精品剧情一区二区三区 | 国产精品久久久久久久久久东京 | 中文字幕在线网站 | 蜜桃一本色道久久综合亚洲精品冫 |