Coder Social home page Coder Social logo

itofu / lctabbarcontroller Goto Github PK

View Code? Open in Web Editor NEW
384.0 13.0 81.0 2.49 MB

A amazing and highly customized tabBarController! You could almost customize 100% properties with LCTabBarController!

Home Page: https://LeoDev.me

License: MIT License

Objective-C 97.96% Ruby 2.04%
tabbar cocoapods tabbarcontroller

lctabbarcontroller's Introduction

LCTabBarController

Travis CocoaPods CocoaPods CocoaPods LeoDev Join the chat at https://gitter.im/iTofu/LCTabBarController

⚠️ Due to busy work, this library WON'T BE SUPPORTED for the moment, please carefully integrate the library.

A amazing and highly customized tabBarController! You could almost customize 100% properties with LCTabBarController! 😍 ✨

by http://LeoDev.me

In me the tiger sniffs the rose.

心有猛虎,细嗅蔷薇。

Welcome to my blog: http://LeoDev.me

中文介绍

Feature

  • Highly decoupled!

    Each control is a independent class! --> means "be possessed":

    LCTabBarBadge --> LCTabBarItem --> LCTabBar --> LCTabBarController

  • Simple integration!

    Integration takes only one step: Just replace the UITabBarController word in your AppDelegate.m with LCTabBarController to complete the integration!

  • Non-Pollution!

    LCTabBarController has all the functions of UITabBarController, and NO any intrusion behavior!

    So, even if your project is complete, you could integrated at any time! You could also change back to UITabBarController! (But I 200% believe you won't do it!)

  • Highly customized!

    You can freely set the following properties, you can also choose to modify the code directly!

    1. tabBar title color

    2. tabbar title font

    3. tabbar image ratio

    4. tabbar badge frame

    5. tabbar badge font

    6. ...

  • If you feel good, please give me a star, thank you very much! ⭐️

    I will keep update with new Issue, if you want to know my progress at any time, please click on the watch button in the upper right corner!

⚠️ NOTE: It doesn't support Storyboard for the time being!

Installation

CocoaPods

LCTabBarController is available on CocoaPods. Just add the following to your project Podfile:

pod 'LCTabBarController' # Podfile

Non-CocoaPods Installation

Just drag the LCTabBarController folder into your project.

Usage

  • Inside your AppDelegate.m:

    // 0. Import header file
    #import "LCTabBarController.h"
    
    // 1. If you have already started the project, even if it's already done.
    UITabBarController *tabBarC = [[UITabBarController alloc] init];
    ->
    LCTabBarController *tabBarC = [[LCTabBarController alloc] init];
    
    // 2. If you're just starting to write a new project
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
        [self.window makeKeyAndVisible];
    
        // Other code
        HomeVC *vc1 = [[HomeVC alloc] init];
        vc1.view.backgroundColor = [UIColor whiteColor];
        vc1.tabBarItem.badgeValue = @"23";
        vc1.title = @"Home";
        vc1.tabBarItem.image = [UIImage imageNamed:@"tabbar_home"];
        vc1.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_home_selected"];
    
        // vc2 vc3 ...
    
        UIViewController *vc4 = [[UIViewController alloc] init];
        vc4.view.backgroundColor = [UIColor yellowColor];
        vc4.tabBarItem.badgeValue = @"99+";
        vc4.title = @"Profile";
        vc4.tabBarItem.image = [UIImage imageNamed:@"tabbar_profile"];
        vc4.tabBarItem.selectedImage = [UIImage imageNamed:@"tabbar_profile_selected"];
    
    
        UINavigationController *navC1 = [[UINavigationController alloc] initWithRootViewController:vc1];
        UINavigationController *navC2 = [[UINavigationController alloc] initWithRootViewController:vc2];
        UINavigationController *navC3 = [[UINavigationController alloc] initWithRootViewController:vc3];
        UINavigationController *navC4 = [[UINavigationController alloc] initWithRootViewController:vc4];
    
    
    
        /**************************************** Key Code ****************************************/
    
        LCTabBarController *tabBarC = [[LCTabBarController alloc] init];
    
        tabBarC.viewControllers = @[navC1, navC2, navC3, navC4];
    
        self.window.rootViewController = tabBarC;
    
        /******************************************************************************************/
    
    
    
        return YES;
    }
  • Done!

  • You can change the following properties with LCTabBarController object, other more attributes can be directly read code changes!

    /**************************************** Key Code ****************************************/
    
    LCTabBarController *tabBarC    = [[LCTabBarController alloc] init];
    
    // look here, you should set this properties before `- setViewControllers:`
    tabBarC.itemTitleFont          = [UIFont boldSystemFontOfSize:11.0f];
    tabBarC.itemTitleColor         = [UIColor greenColor];
    tabBarC.selectedItemTitleColor = [UIColor redColor];
    tabBarC.itemImageRatio         = 0.5f;
    tabBarC.badgeTitleFont         = [UIFont boldSystemFontOfSize:12.0f];
    
    tabBarC.viewControllers        = @[navC1, navC2, navC3, navC4];
    
    self.window.rootViewController = tabBarC;
    
    /******************************************************************************************/

    Than you could see like this:

    by http://LeoDev.me

Example

by http://LeoDev.me


by http://LeoDev.me


by http://LeoDev.me


by http://LeoDev.me

ChangeLog

V 1.3.7

  • Adapt for iOS 11.

  • Improve framework with #27 by tbl00c.

V 1.3.6

  • About #15, public lcTabBar.

V 1.3.5

V 1.3.3

  • Update CocoaPods source URL.

V 1.3.0

  • Bug fixed: Can't find right bundle when using Swift & CocoaPods.

  • building support.

V 1.2.7

  • Bug fixed: #3, thanks for Sesadev's commit!

V 1.2.6

  • Bug fixed:

    When I call the popToRootViewController; method, the origin controls of the system's tabBar is displayed again.

    Now, You should call [lcTabBarController removeOriginControls]; method after popToRootViewController;, like this:

    [self.navigationController popToRootViewControllerAnimated:YES];
    
    [lcTabBarController removeOriginControls];

V 1.2.5

  • Change custom way, experience better!

V 1.2.2

  • Change imageView's contentModel:

    tabBarItem.imageView.contentModel == UIViewContentModeScaleAspectFit;
    
    -->
    
    tabBarItem.imageView.contentModel == UIViewContentModeCenter;

V 1.2.1

  • Fix frame: tabBarBadge's x.

V 1.2.0

  • for you!

V 1.1.0

  • for LanMeng Tec.

  • V 1.1.x will for LanMeng Tec. only.

V 1.0.6

  • for LanMeng Tec.

V 1.0.5

  • Change something:

    tabBarItem.imageView.contentModel == UIViewContentModeCenter;
    
    -->
    
    tabBarItem.imageView.contentModel == UIViewContentModeScaleAspectFit;

V 1.0.3

  • Delete some logs.

  • Update demo images.

V 1.0.2

  • UI adjustment.

V 1.0.1

  • Bug fixed.

V 1.0.0

Support

  • If you have any question, just commit a issue.

  • Mail: echo bGVvZGF4aWFAZ21haWwuY29tCg== | base64 -D

  • Blog: https://LeoDev.me

  • Donations:

    • PayPal:

      Donate

    • Alipay or Wechat Pay:

      Donate with Alipay or Wechat Pay

    Please note: donation does not imply any type of service contract.

License

LCTabBarController is released under the MIT License.

lctabbarcontroller's People

Contributors

gitter-badger avatar itofu avatar sunnysuhappy avatar

Stargazers

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

Watchers

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

lctabbarcontroller's Issues

Second Clicking on same tabbar

Hello
I want to ask a feature if it is possible .
Well Lets imagine In one tab UINavigationController has more than one UIViewControllers for example;
First you navigate 3rd viewcontroller on same tab
After you change the tab
After again you turn the tab before that you opened 3rd viewcontroller it opens ok.
I want to like this If you click this tab again pop to rootviewcontroller in this navigation.
Is it possible ?

大佬求解

lalpbbcc1sqjt6lnbcrnaza_816_1482 png_620x10000q90g

大佬, 我只有4个控制器, 却出现了五个位置, 第五个点击就是这样.懵B了

iPhone X Issues

When i tried to check this on iPhone X, it height get automatically bigger.

Xcode 9.1 iPhone 8 Plus 底部的bar出现重影

在NSURLSessionDataTask的 dataTaskWithRequest:request completionHandler:^的方法里,完成数据请求后,跳转会出现2种情况:
1.采用[self.navigationController pushViewController:lcTabBarVC animated:YES];
animated是YES的情况下,重影出现一小会后消失
2.采用[self.navigationController pushViewController:lcTabBarVC animated:NO];
animated是NO的情况下,重影出现不消失并且第一个视图控制器总是保持选中的状态,下面那个bar的最左边那个图案总是选中的状态
2017-11-08 8 28 35

LCTabBarController问题

有点问题想问问:
1、tabBarC.tabBar.backgroundColor = [UIColor yellowColor];好像设置了没有生效;
2、tabBarC.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"tabbaritem_bg"];好像设置了没有生效;
因为有时需求是选中的tabBarItem的背景跟未选中的不一样。有劳了!

作者写的很好,这儿给出了两个小建议

如题。
1、在LCTabBarController中,有重载setViewControllers:方法初始化自己的tabbar。然而这样可能是不全面的。UITabBarController添加子VC的调用顺序如下:
setViewControllers:-> setViewControllers: animated: ->addChildViewController:
所以,私以为重载addChildViewController:方法最为合理。
2、为移除系统tabBar的items,有removeOriginControls方法,并公开。
在源码和demo中有两处需调用的场景:tabBarController viewWillApper时、业务层修改barItem属性时手动调用。这用起来就有点不太爽了,特别是第二处。
我的建议,首先没必要在viewWillApper中反复调用,如1,在addChildViewController:时调用一次即可。改变title类似情况,通过KVO可以拿到事件,然后反射到LCTabBar直接调用该方法即可。

no tabbar title

Hi,
Thanks for the great project.
What if I don't set the tabbar title, Is there a way to place to image center of the tabbar ?

Thanks ...

TabBarImage Not changing

After doing some event in Any tab except if i am trying to come First tab , its comintg but the tabbar image is not showing select

iPhone X模拟器 重影问题还存在

target 是11.1
在何处初始化:
NSURLSessionDataTask *sessionDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//请求完数据后跳转主页
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf turnToMainViewControllerAnimated];
});
}

MyViewController : UIViewController
初始化代码:
MyViewController *vc4 = [[MyViewController alloc]init];
vc4.view.backgroundColor = [UIColor whiteColor];
vc4.title=@"我的";
vc4.tabBarItem.image = [UIImage imageNamed:@"ic_my.png"];
vc4.tabBarItem.selectedImage = [UIImage imageNamed:@"ic_my_pressed.png"];

LCTabBarController *tabBarC = [[LCTabBarController alloc] init];
tabBarC.itemTitleColor=[XiYeUtilities colorWithHexString:@"#666666"];
tabBarC.selectedItemTitleColor=[XiYeUtilities colorWithHexString:@"#01c0dd"];
tabBarC.viewControllers = @[vc1, vc2, vc3, vc4];

[self.navigationController pushViewController:tabBarC animated:YES];

出现问题:
[self.navigationController pushViewController:tabBarC animated:YES]时会有一瞬间出现下重影,之后消失并能正常使用

[self.navigationController pushViewController:tabBarC animated:NO]时,重影出现后不消失,并且第一个子视图总是处于选中状态,各子视图可以正常点击,就是重影不会消失。

rootViewController removeOriginControls 崩溃

tabar里面的控制器,popToRootViewControllerAnimated 时候removeOriginControls,会崩溃,求原因,
-[UIViewController removeOriginControls]: unrecognized selector sent to instance 0x1022534e0

itemTitleColor和SelectTitleColor 无法动态修改吗?

我这里是继承LCTabBarController的 代码如下:
self.selectedItemTitleColor = [UIColor colorWithRed:44.0f/255.0f green:110.0f/255.0f blue:203.0f/255.0f alpha:1.0];

self.itemTitleColor = [UIColor colorWithRed:191.0f/255.0f green:191.0f/ 255.0f blue:191.0f/255.0f alpha:1]; 主要是体现在换肤的时候我想改变图标下面字体的颜色 发现无法动态修改

内存问题

最近客户端报了几个闪退,找不到原因,检查代码发现这个地方很有嫌疑

  • (void)removeOriginControls {

    [self.tabBar.subviews enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

    if ([obj isKindOfClass:[UIControl class]]) {
    
        [obj removeFromSuperview];
    }
    

    }];
    }
    这个方法是不是有问题,removeFromSuperview是view操作应该是在主线程操作的,但是NSEnumerationConcurrent又是并发,不全是在主线程

Tabbar 重影

你好!
当调用 popToRootViewControllerAnimated Tabbar出现重新,是应为系统的Item与自定义的Item重叠了

Items are not visible

Description:
I had a UITabBarController in my App which I decided to swap for your LCTabBarController. The UITabBarController wasn't being added programmatically, it was added through a Storyboard, so I just changed the Class type in the Storyboard scene.

Expected outcome:
All items are visible like they were when using UITabBarController

Outcome:
Although all items and controllers are present (printing tabBar.items revealed 4 items), none of them is visible nor accessible.

Note:
I find this behaviour pretty weird since in your readme you assure integration should be simply swapping classes...

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.