Coder Social home page Coder Social logo

fujunzhi / futabbarcontroller Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 4.0 1.04 MB

一款简单实用,功能齐全的自定义tabBar,中心按钮可以模态/PUSH,所有标签都可以凸出显示,四种样式随你选择。(选中按钮动画、选中字体可以改变大小颜色、所有按钮都可以凸起、自定义push/模态跳转、角标的自定义)

License: MIT License

Ruby 0.38% Objective-C 99.62%
tabbar tabbarcontroller

futabbarcontroller's Introduction

FUTabBarController

*Custom FUTabBarController 包括功能:选中按钮动画(缩放/旋转)、选中字体可以改变大小颜色、所有按钮都可以凸起、自定义push/模态跳转、角标的自定义

CocoaPods

  1. Add pod 'FUTabBarController', '~> 2.0.1' to your Podfile.

  2. Run pod install or pod update.

  3. 创建UITabBarController自定义类 继承FUTabBarController

  4. 具体实现可以看demoHome->MainTabBarController.m

带动画的效果图

根据有无标题、是否凸出有四种效果

父类中提供的方法

/**
* TabBarSelectAnimationDefault = 0, //无动画
* TabBarSelectAnimationScale,       //缩放动画
* TabBarSelectAnimationRotate       //旋转动画 
*/
@property (nonatomic, assign) TabBarSelectAnimation selectAnimation;

/**
*  初始化一个子控制器
*
*  @param childVc               需要初始化的子控制器
*  @param navigationController  导航控制器
*  @param title                 标题
*  @param imageName             图标
*  @param selectedImageName     选中的图标
*  @param offset                是否凸出(YES:按钮向上凸出)
*/
- (UIViewController *)setupChildViewController:(UIViewController *)childVc navigationController:(Class)navigationController title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName offset:(BOOL)offset;

//添加中心按钮:模态...(子类调用)
- (void)addCenterItemWithIcon:(NSString *)iconName selectedIcon:(NSString *)selectedIconName title:(NSString *)title offset:(BOOL)offset clickBlock:(ClickBlock)block;
@end

子类中给viewControllers赋值就可以了

- (void) setUpChildControllers
{
//动态
UIStoryboard *trendsStB = [UIStoryboard storyboardWithName:@"TrendsViewController" bundle:nil];
TrendsViewController *trendsVC = [trendsStB instantiateViewControllerWithIdentifier:@"TrendsViewController"];
[self setupChildViewController:trendsVC navigationController:[MainNavController class] title:@"动态" imageName:@"trends_nomal.png" selectedImageName:@"trends_select.png" offset:NO];

//名片
UIStoryboard *callingCardStB = [UIStoryboard storyboardWithName:@"CallingCardViewController" bundle:nil];
CallingCardViewController *callingCardVC = [callingCardStB instantiateViewControllerWithIdentifier:@"CallingCardViewController"];
[self setupChildViewController:callingCardVC navigationController:[MainNavController class] title:@"名片" imageName:@"callingCard_nomal.png" selectedImageName:@"callingCard_select.png" offset:NO];

//宝信
UIStoryboard *baoXinStB = [UIStoryboard storyboardWithName:@"BaoXunViewController" bundle:nil];
BaoXunViewController *baoXinVC = [baoXinStB instantiateViewControllerWithIdentifier:@"BaoXunViewController"];
[self setupChildViewController:baoXinVC navigationController:[MainNavController class] title:@"宝信" imageName:@"baoxin_nomal.png" selectedImageName:@"baoxin_select.png" offset:NO];

//我的
UIStoryboard *mineStB = [UIStoryboard storyboardWithName:@"MineViewController" bundle:nil];
MineViewController *mineVC = [mineStB instantiateViewControllerWithIdentifier:@"MineViewController"];
[self setupChildViewController:mineVC navigationController:[MainNavController class] title:@"我的" imageName:@"mine_nomal.png" selectedImageName:@"mine_select.png" offset:NO];

//添加动画
self.selectAnimation = TabBarSelectAnimationScale;

//添加中心按钮
__weak typeof(self) weakSelf = self;
[self addCenterItemWithIcon:@"search_nomal" selectedIcon:@"search_nomal" title:@"搜索" offset:YES clickBlock:^{
    UIStoryboard *board = [UIStoryboard storyboardWithName:@"SearchViewController" bundle:nil];
    SearchViewController *searchVC = [board instantiateViewControllerWithIdentifier:@"SearchViewController"];
    [weakSelf presentViewController:[[MainNavController alloc] initWithRootViewController:searchVC] animated:YES completion:nil];
}];

@end

futabbarcontroller's People

Contributors

fujunzhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

futabbarcontroller's Issues

didSelectedButtonFrom代理只有第一次才进来

  • (void)tabbarAnimationView:(UIView *)view didSelectedButtonFrom:(NSInteger)from to:(NSInteger)to

为什么我只有刚启动的时候会进到这个方法,之后再点击就tabbar就进不到这个方法了?

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.