tabbar怎么些_有关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];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值