bar 1.1 改变 NavigationBar 的背景颜色 [UINavigationBar appearance].barTintColor = [UIColor blueColor]; //如果使用的是...:表示要传一个颜色 [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor...UINavigationBar appearance] setShadowImage:[UIImage new]]; 1.4 改变 TabBar 的字体颜色 [UITabBarItem.appearance setTitleTextAttributes...: @{ NSForegroundColorAttributeName : [UIColor blueColor] } forState:UIControlStateNormal]; [UITabBarItem.appearance...setTitleTextAttributes: @{ NSForegroundColorAttributeName : [UIColor whiteColor] } forState:UIControlStateSelected
:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:RGB_HEX(0x999999)...} forState:UIControlStateNormal]; // [item setTitleTextAttributes:@{NSFontAttributeName:[UIFont...systemFontOfSize:12], NSForegroundColorAttributeName:RGB_HEX(0xfb5400)} forState:UIControlStateSelected...//设置文字样式 NSMutableDictionary *textAttr = [NSMutableDictionary dictionary]; textAttr[NSForegroundColorAttributeName...= [NSMutableDictionary dictionary]; [selectedTextAttr setValue:ktabSelectedTextColor forKey:NSForegroundColorAttributeName
由于项目使用的是自定义的DJNavigationController,而又要保证只设置一次,所以将设置主题的代码写在DJNavigationController.m文件中的initialize方法中。...NSMutableDictionary *normalAttr = [NSMutableDictionary dictionary]; // 设置前景色 normalAttr[NSForegroundColorAttributeName...]; // 设置当前字体大小 normalAttr[NSFontAttributeName] = [UIFont systemFontOfSize:14]; [btnItem setTitleTextAttributes...设置当前item不可用状态 NSMutableDictionary *disableAttr = [NSMutableDictionary dictionary]; disableAttr[NSForegroundColorAttributeName...UIColor grayColor]; disableAttr[NSFontAttributeName] = [UIFont systemFontOfSize:14]; [btnItem setTitleTextAttributes
显示文字自定义颜色) NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIColor orangeColor] forKey:NSForegroundColorAttributeName...]; [vcHome.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected]; 简单的封装下(详见代码...显示文字自定义颜色) NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIColor orangeColor] forKey:NSForegroundColorAttributeName...]; [controller.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected]; }...]; // [vcHome.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected]; 对比如图:
titieview的字体颜色 NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSForegroundColorAttributeName...] = [UIColor whiteColor]; [self.pickerViewController.navigationBar setTitleTextAttributes...] = [UIColor whiteColor]; [self.pickerViewController.navigationBar setTitleTextAttributes...preferredStatusBarStyle { return UIStatusBarStyleLightContent; } @end 由于很多大神分享UIImagePickerController的具体使用方法...,在这里不做多余的阐述了,有问题可以一起讨论。
[item setTitleTextAttributes: @{NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.f green...blue:255/255.f alpha:1],NSFontAttributeName:Font10} forState:UIControlStateNormal]; [item setTitleTextAttributes...: @{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:Font10} forState:UIControlStateSelected
项目告一段落,总结一下项目中遇到的坑 使用 MFMessageComposeViewController 在程序内部发送短信,代码很简单 MFMessageComposeViewController *...UINavigationBar appearance] setShadowImage:[UIImage new]]; //NavigationBar 文字属性 [[UINavigationBar appearance] setTitleTextAttributes...:@{NSForegroundColorAttributeName:WhiteColor}]; 修改方法给NavigationViewController 抽出一个基类 在 viewDidLoad 全局修改...forBarMetrics:UIBarMetricsDefault]; [self.navigationBar setShadowImage:[UIImage new]]; [self.navigationBar setTitleTextAttributes...:@{NSForegroundColorAttributeName:WhiteColor}]; 之后会发现 MFMessageComposeViewController 的NavigationBar 是系统主题的
self.navigationController.navigationBar.barTintColor = [UIColor blackColor]; // 白色文字 // 中间title [self.navigationController.navigationBar setTitleTextAttributes...:@{NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:[UIColor whiteColor...self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]]; [self.navigationItem.rightBarButtonItem setTitleTextAttributes
buttonItem; //导航栏标题 self.navigationItem.title = @"个人中心"; [self.navigationController.navigationBar setTitleTextAttributes...:@{NSForegroundColorAttributeName:[XUtil hexToRGB:@"333333"],NSFontAttributeName:[UIFont systemFontOfSize...; //导航栏标题 self.navigationItem.title = @"单词详解"; [self.navigationController.navigationBar setTitleTextAttributes...:@{NSForegroundColorAttributeName:[XUtil hexToRGB:@"2E2F33"],NSFontAttributeName:[UIFont systemFontOfSize
NSMutableDictionary dictionary]; textAttrs[UITextAttributeTextColor] = [UIColor whiteColor]; [back setTitleTextAttributes...UINavigationItem *)item { //设置导航栏返回按钮文字为透明的,可能造成导航标题不居中的问题 [[UIBarButtonItem appearance] setTitleTextAttributes...:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal]; [[UIBarButtonItem...appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:...UIControlStateHighlighted]; return YES; } 方案三(推荐) 给 UIViewController 添加类别(这里的类别不需要导入可直接使用)
self.navigationBar.translucent = NO; 2.用storyboard设置navigationBar的颜色,XIb上没有属性设置 解决代码: [self.navigationBar setTitleTextAttributes...:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:
NSFontAttributeName: [UIFont systemFontOfSize:12], NSForegroundColorAttributeName... NSFontAttributeName: [UIFont systemFontOfSize:12], NSForegroundColorAttributeName... NSFontAttributeName : [UIFont systemFontOfSize:25], NSForegroundColorAttributeName...: [UIColor greenColor], }; [[UINavigationBar appearance] setTitleTextAttributes
] = [UIColor grayColor]; [vc.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal...] = [UIColor darkGrayColor]; [vc.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected...] = [UIColor grayColor]; [item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal]; //...] = [UIColor darkGrayColor]; [item setTitleTextAttributes:normalAttrs forState:UIControlStateSelected...程序一起动就调用load方法 Initialize方法:初始化类,当第一次使用这个类或者子类的时候调用 viewdidload方法:当viewcontroller第一次即将显示的时候加载。
CYLTabBarController 自己写的Demo Simulator Screen Shot - iPhone 12 Pro - 2021-08-06 at 13.55.35.png 使用也很简单...普通状态下的文字属性 NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary]; normalAttrs[NSForegroundColorAttributeName...选中状态下的文字属性 NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; selectedAttrs[NSForegroundColorAttributeName...:normalAttrs]; [inlineLayoutAppearance.selected setTitleTextAttributes:selectedAttrs];...:normalAttrs forState:UIControlStateNormal]; [tabBar setTitleTextAttributes:selectedAttrs forState
UIBarMetricsDefault]; /** 设置导航栏标题文字颜色 */ NSDictionary *dict = @{ NSForegroundColorAttributeName...: [UIColor whiteColor] }; [navBar setTitleTextAttributes:dict
UIImageRenderingModeAlwaysOriginal]; self.tabBarItem.selectedImage = image; 2:tabBarItem字体设置一下即可,方法如下: [self.tabBarItem setTitleTextAttributes...:@{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];
appearanceWhenContainedIn:self, nil]; NSMutableDictionary * dic = [NSMutableDictionary dictionary]; dic[NSForegroundColorAttributeName...] = [UIColor orangeColor]; // 设置item上文字的颜色 [item setTitleTextAttributes:dic forState:UIControlStateSelected...]; } 在这里首先要说一下initialize这个方法,在初始化的时候会调用,但只调用一次(在使用这个类或者子类的时候调用) 其次说一下appearanceWhenContainedIn:这个方法
UINavigationBar appearance]; navBar.barTintColor = [UIColor redColor]; NSDictionary *dict = @{NSForegroundColorAttributeName...: [UIColor whiteColor]}; [navBar setTitleTextAttributes:dict]; 5.
imageView; } } return nil; } 设置TabBar下面的字体在不同状态下的颜色: [[UITabBarItem appearance] setTitleTextAttributes...:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, nil...] forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary...]; NSForegroundColorAttributeName 是iOS7.0之后才使用的,之前是 UITextAttributeTextColor,关于弃用后如何找到一个替代者,其实很简单,认真阅读...hideTabbar.gif 关于隐藏底部的Tabbar 推荐使用第二种方法,最方便快捷。
green:173/255.0 blue:176/255.0 alpha:1.0]; 设置导航栏title字体类型和大小 [self.navigationController.navigationBar setTitleTextAttributes...fontWithName:@"Helvetica-Bold" size:22], NSForegroundColorAttributeName
领取专属 10元无门槛券
手把手带您无忧上云