自定义TabBarController
来源:互联网 发布:雪鹰领主法器进阶数据 编辑:程序博客网 时间:2024/05/16 15:46
https://github.com/alikaragoz/AKTabBarController
AKTabBarController
AKTabBarController is an adaptive and customizable tab bar for iOS.
Features
- Portrait and Landscape mode tab bar.
- Ability to set the height of the tab bar.
- Ability to hide the tab bar when pushed.
- Ability to set the minimum height of the tab bar to allow display the title.
- Ability to hide the title in the tabs.
- When the height of the tab bar is too small, the title is not displayed.
- Only one image is needed for both selected and unselected states (style is added via CoreGraphics).
- Icons are resized when needed and particularly in landscape mode.
- Animated state of the tabs with a nice cross fade animation.
Preview
iPhone portrait
Usage
Installation
Add the dependency to your Podfile
:
platform :iospod 'AKTabBarController'
Run pod install
to install the dependencies.
Next, import the header file wherever you want to use the tab bar controller:
#import "AKTabBarController.h"
Creation and initialization of the tab bar
// Create and initialize the height of the tab bar to 50px._tabBarController = [[AKTabBarController alloc] initWithTabBarHeight:50];// Adding the view controllers to manage.[_tabBarController setViewControllers:@[[[FirstViewController alloc] init], [[SecondViewController alloc] init], [[ThirdViewController alloc] init], [[FourthViewController alloc] init]]]];
Setting the title and image
(in each view controller)
// Setting the image of the tab.- (NSString *)tabImageName{ return @"myImage";}// Setting the title of the tab.- (NSString *)tabTitle{ return @"Tab";}
Customization
Setting the minimum height to display the title
[_tabBarController setMinimumHeightToDisplayTitle:50];
Hide the tab title
[_tabBarController setTabTitleIsHidden:NO];
Hide the tab bar when pushed in an UINavigationController
When pushing a viewcontroller in the viewControllers stack of an UINavigationController it is possible to hide the tab bar. It works exactely like the original UITabBarController:
[viewController setHidesBottomBarWhenPushed:YES];
Full customization example
// Tab background Image[_tabBarController setBackgroundImageName:@"noise-dark-gray.png"];[_tabBarController setSelectedBackgroundImageName:@"noise-dark-blue.png"];// Tabs top emboss Color[_tabBarController setTabEdgeColor:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.8]];// Tabs colors settings[_tabBarController setTabColors:@[[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.0], [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]]]; // MAX 2 Colors[_tabBarController setSelectedTabColors:@[[UIColor colorWithRed:0.7 green:0.7 blue:0.7 alpha:1.0], [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.0]]]; // MAX 2 Colors// Tab stroke Color[_tabBarController setTabStrokeColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0]];// Icons color settings[_tabBarController setIconColors:@[[UIColor colorWithRed:174.0/255.0 green:174.0/255.0 blue:174.0/255.0 alpha:1], [UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1]]]; // MAX 2 Colors[_tabBarController setSelectedIconColors:@[[UIColor colorWithRed:174.0/255.0 green:174.0/255.0 blue:174.0/255.0 alpha:1], [UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1]]]; // MAX 2 Colors// Text color[_tabBarController setTextColor:[UIColor colorWithRed:157.0/255.0 green:157.0/255.0 blue:157.0/255.0 alpha:1.0]];[_tabBarController setSelectedTextColor:[UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1.0]];// Hide / Show glossy effect on tab icons[_tabBarController setIconGlossyIsHidden:YES];
See below the result of the customization:
For further details see the Xcode example project.
Requirements
- iOS >= 4.3
- ARC
- QuartzCore.framework
Screenshots
iPhone landscape
iPad portrait
iPad landscape
Credits
- Largely inspired by Brian Collins's BCTabBarController (for views imbrication).
- Icons used in the example project are designed by Tomas Gajar (@tomasgajar).
Contact
Ali Karagoz
- http://github.com/alikaragoz
- http://twitter.com/alikaragoz
License
AKTabBarController is available under the MIT license. See the LICENSE file for more info.
- 自定义TabBarController
- 自定义TabBarController
- 自定义TabBarController
- 自定义TabBarController
- 自定义TabBarController
- 自定义TabbarController
- iOS 自定义TabBarController
- 【iOS】自定义TabBarController
- iOS 自定义TabBarController
- iOS 自定义tabBarController
- iOS 自定义TabBarController
- 【iOS】自定义TabBarController
- iOS 自定义TabBarController
- iOS 自定义TabBarController
- 【iOS】自定义TabBarController
- iOS 自定义TabBarController
- iOS 自定义TabBarController
- iOS 自定义TabBarController
- 将 Excel 文件 转换成 CSV 文件 解决方案
- 留给自己的fedora学习笔记2-首次接触做的准备工作
- 什么是B帧、I帧和P帧?B帧、I帧和P帧是什么意思?
- 正则表达式同时匹配中英文_,还控制长度
- 三个和尚的故事 与 项目机构管理
- 自定义TabBarController
- Windows批处理程序的书写来处理文本
- libcurl出现CURLcode 23 CURLE_WRITE_ERROR错误
- boost序列化
- new ActiveXObject("Scripting.FileSystemObject") 时抛出异常,解决方案方法
- log4j配置
- 10044-Erdos number Time limit exceeded
- Cocos2d游戏开发常用工具集合
- Binary XML file line : Error inflating class <unknown> 解决