{"id":15160652,"url":"https://github.com/iwufan/dwscrolltabbarcontroller","last_synced_at":"2025-04-02T17:32:16.314Z","repository":{"id":56908042,"uuid":"87288715","full_name":"iwufan/DWScrollTabBarController","owner":"iwufan","description":"A scrollable tabBar with dynamic items. Each item shows a specific view.","archived":false,"fork":false,"pushed_at":"2018-09-01T11:00:00.000Z","size":64,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T10:02:34.972Z","etag":null,"topics":["ios","objective-c","scrollable","scrollbar","tabbar","tabbarcontroller","uitableview"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iwufan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-05T09:01:09.000Z","updated_at":"2019-10-22T01:22:54.000Z","dependencies_parsed_at":"2022-08-20T19:50:24.108Z","dependency_job_id":null,"html_url":"https://github.com/iwufan/DWScrollTabBarController","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwufan%2FDWScrollTabBarController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwufan%2FDWScrollTabBarController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwufan%2FDWScrollTabBarController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwufan%2FDWScrollTabBarController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwufan","download_url":"https://codeload.github.com/iwufan/DWScrollTabBarController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246860188,"owners_count":20845627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","objective-c","scrollable","scrollbar","tabbar","tabbarcontroller","uitableview"],"created_at":"2024-09-26T23:05:06.576Z","updated_at":"2025-04-02T17:32:16.041Z","avatar_url":"https://github.com/iwufan.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DWScrollTabBarController\n\n- A scrollable tabBar with dynamic items. Each item shows a specific view.\n\n- Swift: You can click [Here](https://github.com/iwufan/DJTabBarController) to get the Swift version of this framework.\n\n# Why shoud I use this framework\n- You can build a view controller with scrollable tabBar in only a few steps.\u003cbr\u003e\n- The items in the tabBar can be dynamic. The items in the tabBar can be different every time you open the view controller. \u003cbr\u003e\n- You don't have to create a class file for each item. What you should do is to create a view for each item.\u003cbr\u003e\n\n- You can use this framework to create view controllers like these below.\n\n- It can be used on iPhoneX now.\n\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example1.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example2.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example3.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example4.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example5.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example6.gif)\n![image](https://github.com/iwufan/Resources/blob/master/Images/DWScrollTabBarController/example7.gif)\n\n# Installation\n- ### Cocoapods\n\n  In your Podfile\n  \n  `pod 'DWScrollTabBarController'`\n  \n- ### Manual import\u003cbr\u003e\n\n  Drag all the files in the `DWScrollTabBarController` folder to your project.\n\n# How to use it\n- ### Extends DWScrollTabBarController \u003cbr\u003e\n  ```\n  #import \"DWScrollTabBarController.h\"\n\n  @interface YourViewController : DWScrollTabBarController\n\n  @end\n  ```\n  NOTE: You can make `DWScrollTabBarController` extends your base ViewController in your project if necessary, instead of extending `UIViewController`.\n  \n- ### Setup customized properties in `viewDidLoad` method\n  ```\n    // color\n    self.normalTitleColor       = [UIColor blackColor];\n    self.currentTitleColor      = [UIColor whiteColor];\n    self.normalButtonBgColor    = [UIColor blueColor];\n    self.currentButtonBgColor   = [UIColor orangeColor];\n    self.tabBarBgColor          = [UIColor whiteColor];\n    // font\n    self.normalTitleFont        = [UIFont systemFontOfSize:13];\n    self.currentTitleFont       = [UIFont systemFontOfSize:18];\n    // height\n    self.tabBarHeight           = 30;\n    // button width\n    self.unifiedWidth           = YES;\n    self.buttonWidth            = 70;\n    // indicator line\n    self.showIndicatorLine      = YES;\n    self.indicatorLineHeight    = 2;\n    self.indicatorLineColor     = [UIColor redColor];\n    self.indicatorLineWidth     = 50;\n    self.indicatorLineCenter    = YES;\n    // bottom line\n    self.showBottomLine         = YES;\n    self.bottomLineHeight       = 1;\n    self.bottomLineColor        = [UIColor blackColor];\n    // margin\n    self.showViewMargin         = YES;\n    self.viewMargin             = 10;\n    self.leftMargin             = 10;\n    self.rightMargin            = 0;\n    self.buttonMargin           = 10;\n    // others\n    self.bounces                = YES;\n    self.scrollable             = YES;\n  ```\n  #### Tip: You DO NOT have to setup all these properties. Every property has a default value.\n    `unifiedWidth` is a special property. It's default value is 'NO', so if you do not set it as 'YES', the tabBar item's width is calculated based on the item's title. The more words on the title, the wider the title.\u003cbr\u003e\n  If you set `unifiedWidth` as 'YES', every item's width will be the same. You should set `buttonWidth` as you want, it has a default value 100. \n  #### Note: If you show `indicatorLine` and `bottomLine` at the same time. The indicator line may be covered by bottom line.\n- ### Setup data in `viewDidLoad` method\n  ```\n    /**\n     !!!!! NOTE:\n      You MUST set properties of tab bar before set value for 'typesArray', otherwise the properties\n      you set for tab bar will not take effect.\n      You can hardcode the types in the code or get the types data from server. It doesn't matter how\n      many types are.\n     */\n    self.typesArray = @[@\"军事\", @\"游戏\", @\"社会\", @\"体育\", @\"娱乐\", @\"头条\", @\"女性\", @\"政治\", @\"时尚\"];\n    \n    // Add all tableviews that need to display data\n    self.tableViewArray = [self setupSubViews];\n  ```\n  #### Tip: You MUST setup data AFTER setting properties. Or you will get nothing in the tabBar.\n  The `setupSubViews` method should be implemented by yourself. Please refer to below for details.\n- ### LoadDefaultData in `viewDidLoad` method\n  ```\n  [self loadTableViewData];\n  ```\n  Load first type's data by default.\n  This method should be implemented by yourself. Please refer to demo for details.\n- ### Create your own tableView to display data.\n  This tableView should have a property `typeID`, and load data in its setter method.\n  ```\n  - (void)setTypeID:(NSString *)typeID {\n    \n      _typeID = typeID;\n\n      [self loadData];\n  }\n  ```\n  Then you can load data based on different types.\n \n  Add them to the property `tableViewArray`\n  ```\n  /**\n   * Add all tableviews that need to display data\n   */\n  - (NSMutableArray *)setupSubViews {\n\n      NSMutableArray *typeTableViews = [NSMutableArray array];\n\n      for (int i = 0; i \u003c self.typesArray.count; i++) {\n\n          DWTableView *tableView = [[DWTableView alloc] init];\n\n          [typeTableViews addObject:tableView];\n      }\n\n      return typeTableViews;\n  }\n  ```\n  ```\n  // Add all tableviews that need to display data\n  self.tableViewArray = [self setupSubViews];\n  ```\n  You can refer to the demo project for the example tableView.\n  \n- ### Implement `DWScrollTabBarController` delegate methods. \n    Please refer to demo for details. You can use the codes of the two methods in the demo directly.\n    ```\n    /**\n     * click buttons in the tab bar\n     */\n    - (BOOL)tabBar:(DWScrollTabBar *)tabBar didClickTabButton:(UIButton *)tabBarButton {\n    \n    // if the click is caused by scroll the tableviews, then don't need to load data\n    BOOL isScrolled = [super tabBar:tabBar didClickTabButton:tabBarButton];\n    \n    if (!isScrolled) {\n        // load data for a specific type\n        [self loadTableViewData];\n    }\n    \n    return NO;\n    }\n    /**\n     * Change page when scroll tableviews\n     */\n    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {\n    \n      [super scrollViewDidEndDecelerating:scrollView];\n      // load data for a specific type\n      [self loadTableViewData];\n    }\n    /**\n     * load data according to types\n     */\n    - (void)loadTableViewData{\n    \n      DWTableView *allView = self.tableViewArray[self.currentPage];\n      allView.typeID = [NSString stringWithFormat:@\"%ld\", self.currentPage];\n    }\n    ```\n  #### Tip: You ONLY can use these two methods above to load every page's data. Please add your 'loadData' method to these two methods.\n  - Above is all you shoud do with this framework. More you shoud do are add customized views to this framework and load data from your server. \u003cbr\u003e\n#### Plese refer to demo for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwufan%2Fdwscrolltabbarcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwufan%2Fdwscrolltabbarcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwufan%2Fdwscrolltabbarcontroller/lists"}