// Set the tab bar Title appearance for normal state. [[UITabbarItem appearance] setTitleTextAttributes:@{ NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-light" size:16],NSForegroundcolorAttributename: [CMK8colors graycolor] } forState:UIControlStatenormal]; // Set the tab bar Title appearance for selected state. [[UITabbarItem appearance] setTitleTextAttributes:@{ NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-Medium" size:16],NSForegroundcolorAttributename: [CMK8colors bluecolor] } forState:UIControlStateSelected];
请帮忙.
解决方法 好消息和坏消息.坏消息,这比使用外观代理要困难一些.
好消息它并没有那么难!
头
#import <UIKit/UIKit.h>@interface MYTabbyVIEwController : UITabbarController@end
履行
#import "MYTabbyVIEwController.h"@implementation MYTabbyVIEwController-(voID)setSelectedVIEwController:(UIVIEwController *)selectedVIEwController{ [super setSelectedVIEwController:selectedVIEwController]; for (UIVIEwController *vIEwController in self.vIEwControllers) { if (vIEwController == selectedVIEwController) { [vIEwController.tabbarItem setTitleTextAttributes:@{ NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-Medium" size:16],NSForegroundcolorAttributename: [UIcolor bluecolor] } forState:UIControlStatenormal]; } else { [vIEwController.tabbarItem setTitleTextAttributes:@{ NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-light" size:16],NSForegroundcolorAttributename: [UIcolor graycolor] } forState:UIControlStatenormal]; } }}
您将需要的最后一部分是使用此子类而不是开箱即用的UITabbarController.如果您正在使用Storyboard,只需选择TabbarController,转到IDentity Inspector(右侧面板中的第三个子选项卡)并将UITabbarController更改为MYTabbarController或您拥有的内容.
但是啊!底线,只需更新VIEwController tabbarItem!
总结以上是内存溢出为你收集整理的更改选定的TabBarItem字体iOS全部内容,希望文章能够帮你解决更改选定的TabBarItem字体iOS所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)