MCSlidingTabs 0.2.2

MCSlidingTabs 0.2.2

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年11月

Maxime Chaillou 维护。




  • Maxime Chaillou

Simple sliding tabs UI element fully customizable for iOS

预览

MCSlidingTabs Top Preview MCSlidingTabs Bottom Preview

文档

初始化

要初始化,这个操作很简单。首先在 UIViewController.h 中子类化您的 UIViewController

#import <UIKit/UIKit.h>
#import "MCSlidingTabs.h"

@interface ViewController : MCSlidingTabs    

@end

然后,在 UIViewController.m 中的 viewDidLoad 方法里

- (void)viewDidLoad {
    [super viewDidLoad];
    UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    [self addTab:@"Red" andImage:[UIImage imageNamed:@"red-icon"] forViewController:[sb instantiateViewControllerWithIdentifier:@"red"]];
    [self addTab:@"Green" andImage:[UIImage imageNamed:@"green-icon"] forViewController:[sb instantiateViewControllerWithIdentifier:@"green"]];
    [self addTab:@"Blue" andImage:[UIImage imageNamed:@"blue-icon"] forViewController:[sb instantiateViewControllerWithIdentifier:@"blue"]];
}

到这里就完成了!您的标签栏现在应该可以工作了。

如果您只想有一个有标题的标签,您可以这样使用

- (void)addTab:(NSString *)tabTitle forViewController: (UIViewController*)vc;

如果您只想有一个图片,可以使用以下代码

- (void)addTabImage:(UIImage *)tabImage forViewController:(UIViewController*)vc;

自定义

您可以在初始化之前更新以下属性,来更改标签栏的颜色,选择位置(底部或顶部)等。

// Color Properties
/*!
 * @brief The color of the text and the image when the tab is not selected.
 */
@property UIColor* foregroundColorNormal;
/*!
 * @brief The color of tab's background when it is not selected.
 */
@property UIColor* backgroundColorNormal;
/*!
 * @brief The color of the text and the image when the tab is selected.
 */
@property UIColor* foregroundColorSelected;
/*!
 * @brief The color of tab's background when it is selected.
 */
@property UIColor* backgroundColorSelected;
/*!
 * @brief The color of the text and the image when the tab is hightlighted (when you press the button).
 */
@property UIColor* foregroundColorHighlighted;
/*!
 * @brief The font used in the tab
 */
@property UIFont* tabFont;



// MCSlidingsTabs Properties
/*!
 * @brief The height of the tab bar. Default = 40.0f.
 */
@property CGFloat barHeight;
/*!
 * @brief The position of the tab bar. Default = MCSlidingTabsPositionBottom.
 */
@property MCSlidingTabsPosition tabBarPosition;
/*!
 * @brief Defines if the views are animated or not (if NO, it looks like default UITabBar). Default = YES.
 */
@property BOOL isAnimatedViews;

如果您想查看一个工作中的应用,项目中有示例可用。