精华内容
下载资源
问答
  • UITabBar

    2016-01-10 20:57:40
    UITabBar

    UITabBarController

    UITabBar

    UITabBarItem


    1. Setting the Delegate
    2. Configuring Tab Bar Items
    3. Supporting User Customization of Tab Bars
    4. Customizing Tab Bar Appearance

    UITabBar是UITabBarController管理的控件,是系统级的VC导航控件

    如上图所示的精品推荐、排行榜和探索等按钮就是一个UITabBar,它和UIToolBar很类似,都是处于屏幕的最下方,和UIToolBar不同的地方是它是系统级管理VC的,能够快速跳转到另一个分支的VC中。

    当你想要定制UITabBar时,只需通过UITabBar.appearance()获取共享的UITabBar,并修改其相关属性即可。

    1 Setting the Delegate

    /// 相关点击代理
    unowned(unsafe) public var delegate: UITabBarDelegate?

    2 Configuring Tab Bar Items

    /// 所有UITabBarItem
    public var items: [UITabBarItem]?
    /// 当前选中的UITabBarItem
    unowned(unsafe) public var selectedItem: UITabBarItem?
    
    /// 是否动画替换[UITabBarItem]
    ///
    /// - parameter items : [UITabBarItem]?
    /// - parameter animated : Bool
    ///
    /// - returns: void
    public func setItems(items: [UITabBarItem]?, animated: Bool)

    3 Supporting User Customization of Tab Bars

    /// 开始定制UITabBarItem,即更多按钮中的导航
    public func beginCustomizingItems(items: [UITabBarItem])
    /// 结束定做[UITabBarItem]
    public func endCustomizingAnimated(animated: Bool) -> Bool
    /// 是否定制[UITabBarItem]
    public func isCustomizing() -> Bool

    4 Customizing Tab Bar Appearance

    /// bar的样色
    @available(iOS 7.0, *)
    public var barStyle: UIBarStyle
    /// 背景色
    @available(iOS 7.0, *)
    public var barTintColor: UIColor? // default is nil
    
    /// item的位置
    @available(iOS 7.0, *)
    public var itemPositioning: UITabBarItemPositioning
    /// item的宽度
    @available(iOS 7.0, *)
    public var itemWidth: CGFloat
    /// item的间距
    @available(iOS 7.0, *)
    public var itemSpacing: CGFloat
    
    /// 按钮颜色
    @available(iOS 5.0, *)
    public var tintColor: UIColor!
    /// 是否透明
    @available(iOS 7.0, *)
    public var translucent: Bool
    /// 背景图片
    @available(iOS 5.0, *)
    public var backgroundImage: UIImage?
    /// 阴影图片
    @available(iOS 6.0, *)
    public var shadowImage: UIImage?
    /// 选中时的背景图像
    @available(iOS 5.0, *)
    public var selectionIndicatorImage: UIImage?

     


    Appendix

    Sample Code

    Swift

    UIKit Framework Reference

    UITabBarController Class Reference

    UITabBar Class Reference

    Revision History

    时间描述
    2016-01-10博文完成

    CSDN:http://blog.csdn.net/y550918116j

    GitHub:https://github.com/937447974/Blog

    展开全文
  • uitabbar

    2020-11-10 17:33:18
    } else { // iOS13 以下 UITabBarItem *item = [UITabBarItem appearance]; [item setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal]; [item ...

    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
        //单击处理
        int i=0;
        UINavigationController *navdid=tabBarController.selectedViewController;//当前状态下已经处于选择状态的vc
        UINavigationController *nav=(UINavigationController*)viewController;//点击的vc
        if (![navdid.topViewController isEqual:self]) {//这里是判断nav的rootviewcontroller,但是这一层时它里面只有onetableviewcontroller这一个控制器,所以我们可以判断topViewController就是它了,这个属性是取栈定控制器。
            i--;//如果是从别的页面切换过来则不用立马做未读消息处理,让i的值随意变动一下,不等于1就行了
        }

        if ([nav.topViewController isEqual:self]) {
            i++;
            NSLog(@"点击了消息页面,i的值为%d",i);

        }
        if (i==1) {
            //这里做未读消息滚动处理或者刷新功能处理,如果这个页面里面有分了两个小页面,可以使用block和delegate,当然我建议使用block,比代理模式简单又好用。

     

        }

        return YES;//这里做一下解释,该方法用于控制TabBarItem能不能选中,返回NO,将禁止用户点击某一个TabBarItem被选中。

     

    }

        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41

    #import "OneTableViewController.h"

    @interface OneTableViewController ()<UITabBarControllerDelegate>
    @property(nonatomic,assign)int i;
    @end

    @implementation OneTableViewController

    -(void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        self.i=0;
    }
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tabBarController.delegate=self;
        self.navigationItem.title=@"消息";
    }
        //双击处理,这里双击是指的点击两次,当然可以不连续。如果非要做到那种连续快速点击两次,我们还要做一个点击间隔的时间判断,这个少尉麻烦一点就不去试了,原谅我的懒惰.有兴趣的同学可以用时间戳来实现,用一个全局变量记录第一次点击时间,然后和第二次点击时间对比,如果间隔在自己设置的连续点击时间内(比如我们认为两次点击时间间隔在1秒内认为就是双击),就判断为双击,否则就认为单击,让第二次点击时间在赋给那个全局变量接着做判断,当然这里还有一些比如三连击等,要注意在判断双击之后再做一次判断以防三连击当成两次双击做处理了就行了。
    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{

        //双击处理
        UINavigationController *navdid=tabBarController.selectedViewController;
        UINavigationController *nav=(UINavigationController*)viewController;
        if (![navdid.topViewController isEqual:self]) {
            self.i--;
        }

        if ([nav.topViewController isEqual:self]) {
            self.i++;
        }
        if (self.i==2) {
            self.i=0;
            NSLog(@"点击两次");
            //这里做逻辑处理就行了
        }
        return YES;

    }

    获取item位置

    CGRect rect = [self getTabBarItemFrameWithCount:4 index:2];

    - (CGRect)getTabBarItemFrameWithCount:(NSInteger)count index:(NSInteger)index
    {
        NSInteger i = 0;
        CGRect itemFrame = CGRectZero;
        for (UIView *view in self.tabBarController.tabBar.subviews) {
            if (![NSStringFromClass([view class]) isEqualToString:@"UITabBarButton"]) {
                continue;
            }
            //找到指定的tabBarItem
            if (index == i++) {
                itemFrame = view.frame;
                break;
            }
        }
        
        return itemFrame;
    }

    tabbar跳转

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

        UITabBarController *tabViewController = (UITabBarController *) appDelegate.window.rootViewController;

        [tabViewController setSelectedIndex:2];

    设置文字颜色

    // 方式三:适配iOS13
        if (@available(iOS 13.0, *)) {
                // iOS13 及以上
                self.tabBar.tintColor = RGB(254, 195, 10, 1);
                self.tabBar.unselectedItemTintColor = [UIColor blackColor];
         }
        else {
               // iOS13 以下
               UITabBarItem *item = [UITabBarItem appearance];
               [item setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal];
               [item setTitleTextAttributes:@{ NSForegroundColorAttributeName:RGB(254, 195, 10, 1)} forState:UIControlStateSelected];
         }

     

    设置图片无效

    viewController.tabBarItem.image = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_unsel", imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        viewController.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_sel", imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    设置颜色

     

    // 设置一个自定义 View,大小等于 tabBar 的大小
        UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
        // 给自定义 View 设置颜色
        bgView.backgroundColor = [UIColor redColor];
        // 将自定义 View 添加到 tabBar 上
        [self.tabBar insertSubview:bgView atIndex:0];
    

    注意:

    1. 以上代码要写在 appdelegate.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法里面
    展开全文
  • UITabbar

    2015-01-23 11:29:14
    // [[UITabBar appearance] setBackgroundImage:[tabBarBackground resizableImageWithCapInsets:UIEdgeInsetsZero]]; // [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_...


    
    @interface MainVC : UITabBarController<UITabBarControllerDelegate>
    
    @end
    
    
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        if (SystemVersion > 6.0)
            [UITextField appearance].tintColor = [UIColor grayColor];
            
            [[UITabBar appearance] setTintColor:kBtnNomalColor];
        
        //初始化控制器
        PatientMainVC * patientVC = [[PatientMainVC alloc]init];
        MessageListVC * messageListVC = [[MessageListVC alloc]init];
        ToolVC * toolVC = [[ToolVC alloc]init];
        //    PersonalVC * personalVC = [[PersonalVC alloc]init];
        
        PersonalPageVC * personalVC = [[PersonalPageVC alloc]init];
        
        
        NSArray * ctrArray = [[NSArray alloc]initWithObjects:patientVC,messageListVC,toolVC,personalVC, nil];
        self.viewControllers = ctrArray;
        self.selectedViewController = patientVC;
        
        
        self.tabBar.layer.borderWidth = 0.5;
        self.tabBar.layer.borderColor = kNavBottomColor.CGColor;
        self.tabBar.layer.backgroundColor = kNavColr.CGColor;
        [self.tabBar setClipsToBounds:YES];
        [self.tabBar setTintColor:kNavColr];
        //    [self.tabBar setBackgroundColor:[UIColor purpleColor]];
        
        
        //初始化tabBar
        UITabBar *tabBar = self.tabBar;
        UITabBarItem *aTabBarItem = [tabBar.items objectAtIndex:0];
        UITabBarItem *bTabBarItem = [tabBar.items objectAtIndex:1];
        UITabBarItem *cTabBarItem = [tabBar.items objectAtIndex:2];
        UITabBarItem *dTabBarItem = [tabBar.items objectAtIndex:3];
        
        aTabBarItem.title = @"病人";
        bTabBarItem.title = @"消息";
        cTabBarItem.title = @"工具";
        dTabBarItem.title = @"我";
        
        
        [aTabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"patient_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"patient_default"]];
        [bTabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"message_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"message_default"]];
        [cTabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tool_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"tool_default"]];
        [dTabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"mine_selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"mine_default"]];
        
        //    UIImage* tabBarBackground = [UIImage imageNamed:@"tabbarbg.png"];
        //    [[UITabBar appearance] setBackgroundImage:[tabBarBackground resizableImageWithCapInsets:UIEdgeInsetsZero]];
        //    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]];
        
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                           [UIColor grayColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal];
        
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                           kBtnNomalColor, UITextAttributeTextColor,nil] forState:UIControlStateSelected];
    }
    
    


    展开全文
  • UITabBar UITabBarItem 自定义

    千次阅读 2018-05-03 09:50:31
    UITabBar 自定义详细解读 不得不说UITabBar神一般的存在 使用过UITabbar的人都知道, 很多App开发都挺喜欢用UITabbar,系统的UITabbar的确很方便,省事,强大的iOS 的api给开发带来很多便利,我们看看企鹅开发的...

    UITabBar 自定义详细解读

    不得不说UITabBar神一般的存在

    使用过UITabbar的人都知道, 很多App开发都挺喜欢用UITabbar,系统的UITabbar的确很方便,省事,强大的iOS 的api给开发带来很多便利,我们看看企鹅开发的微信就知道了 。。。。 微信的iOS 版就使用了UITabbar,而且可以猜测,八成是用的系统自带的 为啥敢这样下结论,微信不会浪费性能在花哨的UI上的,支付宝的大框架也是UITabbar,还有美团等等 。。。。。
    不管是支付宝,微信还是美团 , 他们的UITabbar都有个特点 。。。
    这里写图片描述

    第一: 每个UITabBarItem 都包含图片和文字 ,而且包含两种状态,选中和未选中
    第二:无论选中或者未选中,图片和文字的布局都不变
    这种UITabbar是程序猿最喜欢的,因为代码最少,性能最高
    But , 还有一种 UITabBarItem 只有图片 , 有代表性的是 Facebook
    这里写图片描述

    以上两种都比较好办,只有图片的话其实通过移动 系统 UITabBarItem 中图片的位置也可以处理好的 , 但是有些比较 恶心的 UITabBarItem ,观赏下 。。。
    这里写图片描述

    自定义UITabBarItem

    1.通常情况下设计师不懂技术更不懂所谓的性能,模仿的居多,看到别人这样TA也这样;企鹅微信的UI是我见过最简洁且比较容易实现的UI , UITabBarItem为啥微信不自定义了 ? 朋友圈的图片为啥限制在9张之内了 ? 为啥都采用iOS 系统的UITableView了 ? 只能说企鹅的设计师还是有两把刷子的,至少是很懂iOS系统的 。。。。
    2.大部分小公司的设计呵呵, 能力没有,怼起来牛逼,你见过高度是 55 的 UITabBar 我就见过,而且语不惊人死不休,来一句“等比放大” 。。。。 无需多吐槽,懂得自然懂。。。

    1.首先定义UITabBarItem#####

    简单的说,把单个的Item当做一个View来看待就可以 ,图片,文字,大图等 。。。。。
    就以我上面截图来说

    #import <UIKit/UIKit.h>
    
    @interface HbTabBarItem : UIView{
        UILabel *textLabel;
        UIImage *select,*unselect;
        UIImageView *iconImage;
        UIImageView *bigImage;
    
    }
    -(instancetype)initWithTitle:(NSString*)title unselectImage:(NSString * )unsimage selectedImage:(NSString *)selectImg size:(CGSize)imgSize;
    -(void)setItemSelected:(BOOL)itemSelected tag:(NSInteger)tag;
    @end
    #import "HbTabBarItem.h"
    #import "Masonry.h"
    
    
    #define RGBA(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
    #define RGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]
    
    
    #define HEXRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
    #define HEXRGBA(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
    
    
    #define COLOR_666666 HEXRGB(0x666666)
    #define COLOR_abaaaa HEXRGB(0xabaaaa)
    
    #define FONT_MEDIUM @"PingFangSC-Medium"
    #define FONT_REGULAR @"PingFangSC-Regular"
    #define FONT_SEMIBOLD @"PingFangSC-Semibold"
    #define FONT_SC @"PingFangSC"
    
    
    @implementation HbTabBarItem
    
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect {
        // Drawing code
    }
    */
    -(instancetype)init{
        if(self=[super init]){
    
        }
        return self;
    }
    
    -(void)awakeFromNib{
        [super awakeFromNib];
    
    }
    
    -(void)setup{
        textLabel = [[UILabel alloc] init];
        textLabel.font = [UIFont fontWithName:FONT_REGULAR size:11];
        textLabel.text = @"  ";
        [self addSubview:textLabel];
        [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-4);
            make.centerX.equalTo(self);
        }];
        iconImage = [[UIImageView alloc] init];
        iconImage.image = [UIImage imageNamed:@"bar1_selected"];
        [self addSubview:iconImage];
        [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(16, 16));
            make.bottom.equalTo(self).offset(-26);
            make.centerX.equalTo(self);
        }];
    
        bigImage = [[UIImageView alloc] init];
        bigImage.image = [UIImage imageNamed:@"bar1_selectImage"];
        [self addSubview:bigImage];
        [bigImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(42, 42));
            make.center.equalTo(self);
        }];
        bigImage.hidden = YES;
    }
    
    -(instancetype)initWithTitle:(NSString*)title unselectImage:(NSString * )unsimage selectedImage:(NSString *)selectImg size:(CGSize)imgSize{
        self=[super init];
        [self setup];
    
    
        select = [UIImage imageNamed:selectImg];
        unselect = [UIImage imageNamed: unsimage];
        textLabel.text = title;
        [iconImage setImage:select];
        [iconImage mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(imgSize);
            make.bottom.equalTo(self).offset(-24);
            make.centerX.equalTo(self);
        }];
        return self;
    }
    
    -(void)setItemSelected:(BOOL)itemSelected tag:(NSInteger)tag{
    
    
        if (itemSelected && tag == 0) {
            bigImage.hidden = NO;
            textLabel.hidden = YES;
            iconImage.hidden = YES;
        }else{
            bigImage.hidden = !NO;
            textLabel.hidden = !YES;
            iconImage.hidden = !YES;
        }
    
        if (itemSelected) {
            iconImage.image = select;
            textLabel.textColor = COLOR_666666;
        }else{
            iconImage.image = unselect;
            textLabel.textColor = COLOR_abaaaa;
        }
    
    }
    @end
    

    以上是定义单个的 Item ,然后就想把Item放在一起
    也就是自定定义tabbar

    #import <UIKit/UIKit.h>
    
    @class HbTabBarItem;
    
    @interface HbTabbar : UITabBar
    @property(strong, nonatomic) NSArray <HbTabBarItem*> *tabItems;
    -(void)setCurrentIndex:(NSInteger)tag;
    @end
    
    #import "HbTabbar.h"
    #import "HbTabBarItem.h"
    
    
    @implementation HbTabbar
    
    -(instancetype)initWithFrame:(CGRect)frame{
        if(self=[super initWithFrame:frame])
        {
            self.translucent=NO;
    
        }
        return self;
    }
    -(void)clearView{
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    }
    
    -(void)setTabItems:(NSArray *)tabItems{
        _tabItems=tabItems;
        [self clearView];
        for (int i=0; i<tabItems.count; i++) {
    
            HbTabBarItem *barItem=tabItems[i];
            [self addSubview:barItem];
        }
    
        [self setCurrentIndex:0];
    }
    
    
    -(void)setCurrentIndex:(NSInteger)tag{
    
        for (int i=0; i<self.tabItems.count; i++) {
            HbTabBarItem *barItem=self.tabItems[i];
            [barItem setItemSelected:i==tag tag:tag];
    
        }
    }
    
    - (void)layoutSubviews{
        [super layoutSubviews];
        [self setupTabBarItems];
    }
    - (void)setupTabBarItems
    {
        CGFloat w = self.frame.size.width;
        CGFloat h = self.frame.size.height;
    
        int count = (int)self.tabItems.count;
        CGFloat itemY = 0;
        CGFloat itemW = w / count;
        CGFloat itemH = h;
    
        for (int index = 0; index < count; index++) {
            HbTabBarItem *tabBarItem = self.tabItems[index];
            CGFloat itemX = index * itemW;
            tabBarItem.frame = CGRectMake(itemX, itemY, itemW, itemH);
        }
    }
    
    @end

    不用多解释 ,复制代码就行 ,
    然后就是使用了 。。。。。。

    #import "ViewController.h"
    
    #import "HbTabbar.h"
    #import "HbTabBarItem.h"
    
    #import "V1ViewController.h"
    #import "V2ViewController.h"
    #import "V3ViewController.h"
    #import "V4ViewController.h"
    #define AppFrameWidth  [UIScreen mainScreen].bounds.size.width
    #define AppFrameHight [UIScreen mainScreen].bounds.size.height
    
    
    
    
    @interface ViewController ()<UITabBarControllerDelegate>{
        UITabBarController  *viewController;
        HbTabbar *hbTabbar;
    
    }
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        V1ViewController *h1 = [[V1ViewController alloc] init];
        HbTabBarItem *t1 = [[HbTabBarItem alloc] initWithTitle:@"首页" unselectImage:@"bar1_unselected" selectedImage:@"bar1_unselected" size:CGSizeMake(18, 16)];
    
    
         V2ViewController *h2 = [[V2ViewController alloc] init];
         HbTabBarItem *t2 = [[HbTabBarItem alloc] initWithTitle:@"联系人" unselectImage:@"bar2_unselected" selectedImage:@"bar2_selected" size:CGSizeMake(16, 16)];
    
    
    
         V3ViewController *h3 = [[V3ViewController alloc] init];
        HbTabBarItem *t3 = [[HbTabBarItem alloc] initWithTitle:@"收藏" unselectImage:@"bar3_unselected" selectedImage:@"bar3_selected" size:CGSizeMake(18, 16)];
    
    
    
         V4ViewController *h4 = [[V4ViewController alloc] init];
         HbTabBarItem *t4 = [[HbTabBarItem alloc] initWithTitle:@"其他" unselectImage:@"bar4_unselected" selectedImage:@"bar4_selected" size:CGSizeMake(17, 19)];
    
    
    
    
    
        UINavigationController *h11 = [[UINavigationController alloc] initWithRootViewController:h1];
        UINavigationController *h22 = [[UINavigationController alloc] initWithRootViewController:h2];
        UINavigationController *h33 = [[UINavigationController alloc] initWithRootViewController:h3];
        UINavigationController *h44  = [[UINavigationController alloc] initWithRootViewController:h4];
    
    
        NSArray *viewControllers = [NSArray arrayWithObjects:h11,h22,h33,h44, nil];
    
    
        viewController = [[UITabBarController alloc] init];
    
    
        hbTabbar = [[HbTabbar alloc] initWithFrame:viewController.tabBar.frame];
        //    hbTabbar.ydelegate=self;
        [viewController setValue:hbTabbar forKeyPath:@"tabBar"];
        hbTabbar.tabItems=@[t1,t2,t3,t4];
    
        viewController.delegate = self;
        viewController.viewControllers = viewControllers;
        viewController.view.frame = CGRectMake(0, 0, AppFrameWidth, AppFrameHight);
        [viewController.tabBar setClipsToBounds:YES];
    //    [viewController.tabBar insertSubview:backView atIndex:0];
        viewController.tabBar.opaque = YES;
        [self.view addSubview:viewController.view];
    
    }
    
    -(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    
        [hbTabbar setCurrentIndex:tabBarController.selectedIndex];
    
    }
    

    最后,小公司的APP不存在效率问题—因为没人用

    源码 下载地址: https://download.csdn.net/download/chmod_r_755/10388492

    展开全文
  • 自定义UITabbar

    2013-07-16 10:41:28
    自定义UITabbar
  • UITabBar自定义

    2017-04-12 11:21:37
    UITabBar自定义,顶部曲线,中间按钮突出(OC)
  • 定制UITabBar

    2013-10-14 12:08:27
    自定义UITabBar,实现自己想要的TabBar效果,只需修改图片及期大小即可。
  • UITabBar 自定义

    2015-09-01 21:57:16
    UITabBar 自定义
  • 实用UITabBar

    2012-09-07 15:17:44
    非常实用的自定义控件UITabBar,简单实用,方便开发,起到了更加美化界面的作用。
  • import UIKit class TabBarVC: UITabBarController { override func viewDidLoad() { super.viewDidLoad() tabBar.tintColor = ... let itemRecord: UITabBarItem = tabBar.items![0] let itemEquipment: UITa
  • UITabBar Contoller

    2019-08-07 20:22:45
    UITabBar中的UIViewController获得控制权: 在TabBar文件中添加: IBOutlet UITabBar *myTabBar; //在xib中连接tabBar; (void)tabBarController:(UITabBarController *)tabBarController ...
  • UITabBar颜色

    2015-09-30 14:22:18
    [[UITabBar appearance] setTintColor:你的颜色];  [[UITabBar appearance] setTranslucent:NO];  [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
  • UITabBar动画隐藏 用法: tabBarController ? . tabBar . isTranslucent = true tabBarController ? . setTabBarHidden ( true , animated : true )
  • UITabBarItem

    2016-01-11 14:53:05
    UITabBarItem就是UITabBar上显示的小按钮
  • 主要为大家详细介绍了iOS自定义UITabBar中间按钮,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • UITabBar的自定义

    2013-11-03 00:20:38
    通过自定义,实现与官方的UITabBar的不同效果

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 6,307
精华内容 2,522
关键字:

uitabbar