//tabbar item在各个样式的下的布局
//上下结构tabbar item布局
UITabBarItemAppearance *stack_apperance = [[UITabBarItemAppearance alloc] initWithStyle:UITabBarItemAppearanceStyleStacked];
stack_apperance.normal.titlePositionAdjustment = UIOffsetMake(0, 1);
stack_apperance.selected.titlePositionAdjustment = UIOffsetMake(0, 1);
stack_apperance.normal.titleTextAttributes = @{NSForegroundColorAttributeName: color, NSFontAttributeName:UIFont.bb_12};
stack_apperance.selected.titleTextAttributes = @{NSForegroundColorAttributeName: scolor, NSFontAttributeName:UIFont.bb_12};
//左右结构tabbar item布局(左右结构时字体一定要比上下布局小,否则会由于间隔问题导致文字显示不全)
UITabBarItemAppearance *inline_apperance = [[UITabBarItemAppearance alloc] initWithStyle:UITabBarItemAppearanceStyleInline];
inline_apperance.normal.titleTextAttributes = @{NSForegroundColorAttributeName: color, NSFontAttributeName:UIFont.bb_10};
inline_apperance.selected.titleTextAttributes = @{NSForegroundColorAttributeName: scolor, NSFontAttributeName:UIFont.bb_10};
//左右结构被挤压时的tabbar item布局(某些特殊情况,只会出现在ipad上,比如多屏侧边栏出现时会压缩app的宽度)
UITabBarItemAppearance *compact_apperance = [[UITabBarItemAppearance alloc] initWithStyle:UITabBarItemAppearanceStyleCompactInline];
compact_apperance.normal.titleTextAttributes = @{NSForegroundColorAttributeName: color, NSFontAttributeName:UIFont.bb_7};
compact_apperance.selected.titleTextAttributes = @{NSForegroundColorAttributeName: scolor, NSFontAttributeName:UIFont.bb_7};
//tabbar item样式类
UITabBarAppearance *bar_a = [UITabBarAppearance new];
bar_a.stackedLayoutAppearance = stack_apperance;
bar_a.inlineLayoutAppearance = inline_apperance;
bar_a.compactInlineLayoutAppearance = compact_apperance;
//tabbar item
UITabBarItem *tab = [[UITabBarItem alloc] initWithTitle:title image:icon selectedImage:sicon];
tab.imageInsets = UIEdgeInsetsZero;
tab.standardAppearance = bar_a;
tab.scrollEdgeAppearance = bar_a;
iOS 设置UITabBarItem
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- -(void)setTabBarItem:(UITabBarItem*)tabbarItem Title:(NSS...
- 1.改变UITabBarItem 字体颜色 [[UITabBarItemappearance]setTitleTe...
- iOS13碰到设置tabbar字体为选中状态颜色,正常切换没有问题,push后再返回,选中颜色变化系统蓝色目前碰到...
- iOS13碰到设置tabbar字体为选中状态颜色,正常切换没有问题,push后再返回,选中颜色变化系统蓝色解决方法...
- 使用新版XcodeVersion 11.2.1 (11B500)创建项目时,发现对UITabController的...