Giter VIP home page Giter VIP logo

menucomponent's Introduction

MenuComponent

License MIT  CocoaPods  CocoaPods 

多功能滑动菜单,实现各控制器的滚动展示,支持点击、左右滑动以及分级。

MenuComponent

安装 [CocoaPods]

  1. pod 'MenuComponent', '~> 1.1';
  2. pod install / pod update;
  3. #import <MenuComponent/MenuTabBarController.h>.

使用说明

本组件,包含:MenuTabBarControllerMenuTabBar,两者均可单独使用。其中MenuTabBarController通过使用addChildViewController将各子控制器加在同一父控制器中,通过点击菜单按钮或滑动,实现各子控制器的切换。部分UI可通过以下属性自行设置。

顶部菜单类型:

typedef enum {
    MenuTabBarTypeNormal = 0,   //同级:仅有文字,宽度由文字决定
    MenuTabBarTypeAverage,      //同级:仅有文字,宽度均分
    MenuTabBarTypeArrow,        //分级:可逐级点击
    MenuTabBarTypeImage         //同级:图在上文字在下,宽度均分

} MenuTabBarType;

MenuTabBarController属性:

//代理
@property (nonatomic,assign) id<MenuTabBarControllerDelegate> delegate;
//类型
@property (nonatomic,assign) MenuTabBarType tabBarType;
//子控制器是否可以滑动
@property (nonatomic,assign) BOOL scrollEnabled;
//点击切换是否有滚动动画
@property (nonatomic,assign) BOOL scrollAnimation;
//点击切换文字是否变大
@property (nonatomic,assign) BOOL enlargeEnabled;
//顶部菜单高度
@property (nonatomic,assign) CGFloat tabBarHeight;
//字体
@property (nonatomic,strong) UIFont *font;
//标签颜色
@property (nonatomic,strong) UIColor *indicatorColor;
//被选中标签的颜色
@property (nonatomic,strong) UIColor *currentIndicatorColor;
//标示线颜色
@property (nonatomic,strong) UIColor *indicatorLineColor;
//文字数组
@property (nonatomic,strong) NSArray *titleArray;
//图片名称数组
@property (nonatomic,strong) NSArray *imageNameArray;
//子控制器数组
@property (nonatomic,strong) NSArray *subViewControllers;
//MenuTabBarTypeArrow类型下的arrow图片名称
@property (nonatomic,copy) NSString *arrowImageName;
//当前选择的Index
@property (nonatomic,assign,readonly) NSInteger currentIndex;

//### 外部接口

//更新菜单
- (void)updateData;
//设置父控制器
- (void)setParentController:(UIViewController *)viewController;

具体使用如下:

MenuTabBarController *tabBarController = [[MenuTabBarController alloc] init];
tabBarController.tabBarType = MenuTabBarTypeImage;
tabBarController.delegate = self;
tabBarController.scrollEnabled = NO;
tabBarController.scrollAnimation = NO;
tabBarController.font = [UIFont systemFontOfSize:15.0];
tabBarController.indicatorColor = [UIColor blackColor];
tabBarController.currentIndicatorColor = [UIColor redColor];
tabBarController.indicatorLineColor = [UIColor redColor];
tabBarController.titleArray = @[@"新朋友",@"群聊",@"公众号"];
tabBarController.imageNameArray = @[@"item_0",@"item_1",@"item_2"];
tabBarController.subViewControllers = @[firstVC,seconVC,thirdVC];
[tabBarController setParentController:self];
#pragma mark - MenuTabBarControllerDelegate
- (void)tabBarController:(MenuTabBarController *)tabBarController didSelectAtIndex:(NSInteger)index
{
    NSLog(@"点击Index:%d",index);
}

使用要求

  • iOS 7.0 or later.
  • Xcode 7.0 or later.
  • OS X 10.10 or later.

许可证

MIT

menucomponent's People

Contributors

chaneylau avatar

Stargazers

 avatar

Watchers

Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.