zoukankan      html  css  js  c++  java
  • 有关TabBar的一些性质

    // 计入导航控制器时,要使得底部的TabBar消消失

    test.hidesBottomBarWhenPushed = YES;

    /**

     *  布局子控件

     */

    - (void)layoutSubviews

    {

        [super layoutSubviews];

        

        // NSClassFromString(@"UITabBarButton") == [UITabBarButton class]

        // NSClassFromString(@"UIButton") == [UIButton class]

        

        /**** 设置所有UITabBarButton的frame ****/

        // 按钮的尺寸

        CGFloat buttonW = self.frame.size.width / 5;

        CGFloat buttonH = self.frame.size.height;

        CGFloat buttonY = 0;

        // 按钮索引

        int buttonIndex = 0;

        

        for (UIView *subview in self.subviews) {

            // 过滤掉非UITabBarButton

            //  if (![@"UITabBarButton" isEqualToString:NSStringFromClass(subview.class)]) continue;

            if (subview.class != NSClassFromString(@"UITabBarButton")) continue;

            

            // 设置frame

            CGFloat buttonX = buttonIndex * buttonW;

            if (buttonIndex >= 2) { // 右边的2个UITabBarButton

                buttonX += buttonW;

            }

            subview.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);

            

            // 增加索引

            buttonIndex++;

        }

        

        /**** 设置中间的发布按钮的frame ****/

        self.publishButton.frame = CGRectMake(0, 0, buttonW, buttonH);

        self.publishButton.center = CGPointMake(self.frame.size.width * 0.5, self.frame.size.height * 0.5);

    }

    /////////////////////////////

    // 修改控件的外观颜色

    [UISwitch appearance].onTintColor = [UIColor orangeColor];

    /*设置TabBarViewController控制器的颜色*/

    /** 文字属性 **/

    // 普通状态下的文字属性

    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];

    normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:20];

    normalAttrs[NSForegroundColorAttributeName] = [UIColor redColor];

    // 选中状态下的文字属性

    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];

    selectedAttrs[NSForegroundColorAttributeName] = [UIColor greenColor];

     

    // 创建窗口

    self.window = [[UIWindow alloc] init];

    self.window.frame = [UIScreen mainScreen].bounds;

    // 设置根控制器

    UITabBarController *tabBarVc = [[UITabBarController alloc] init];

    UITableViewController *vc0 = [[UITableViewController alloc] init];

    vc0.view.backgroundColor = [UIColor redColor];

    vc0.tabBarItem.title = @"精华";

    [vc0.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];

    [vc0.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];

    vc0.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];

    vc0.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_essence_click_icon"];

    [tabBarVc addChildViewController:vc0];

  • 相关阅读:
    记录上锁(字节范围锁,特例:锁住文件的某一部分或者整个文件)
    读写锁的实现原理(pthread_rwlock_t)
    Linux 互斥锁的实现原理(pthread_mutex_t)
    System V消息队列
    Web安全之SQL注入攻击技巧与防范
    如何正确地写出单例模式
    java的concurrent用法详解
    java并发编程-Executor框架
    java.util.concurrent包分类结构图
    Java多线程干货系列(1):Java多线程基础
  • 原文地址:https://www.cnblogs.com/1018475062qq/p/6256811.html
Copyright © 2011-2022 走看看