iOS 7-导航栏项目文本颜色
我对iOS7上导航栏项的文本颜色有问题 所有的事情都很好,直到我提出了一个viewcontroller,从这个时候起,所有的导航栏项目文本颜色都是灰色的。你对这个问题有经验吗 用于表示VC的代码:iOS 7-导航栏项目文本颜色,ios,ios7,uipopovercontroller,uinavigationitem,presentmodalviewcontroller,Ios,Ios7,Uipopovercontroller,Uinavigationitem,Presentmodalviewcontroller,我对iOS7上导航栏项的文本颜色有问题 所有的事情都很好,直到我提出了一个viewcontroller,从这个时候起,所有的导航栏项目文本颜色都是灰色的。你对这个问题有经验吗 用于表示VC的代码: [passcodePopover presentPopoverFromRect:CGRectMake([UIScreen mainScreen].bounds.size.width/2 ,currentWindow.frame.size.height/2,1,1)
[passcodePopover presentPopoverFromRect:CGRectMake([UIScreen mainScreen].bounds.size.width/2 ,currentWindow.frame.size.height/2,1,1)
inView:currentWindow
permittedArrowDirections:0 animated:NO];[passcodePopover presentPopoverFromRect:CGRectMake([UIScreen mainScreen].bounds.size.width/2 ,currentWindow.frame.size.height/2,1,1)
inView:currentWindow
permittedArrowDirections:0 animated:NO];
在passcodePopover的viewdidLoad方法中,您将希望使用此代码
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:textTitleOptions];
如果您的popover中没有navigationController,则必须稍微更改代码,而且您可能不想使用[UIColor whiteColor]。替换您自己选择的颜色。在passcodePopover的viewdidLoad方法中,您将希望使用此代码
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:textTitleOptions];
如果您的popover中没有navigationController,则必须稍微更改代码,而且您可能不想使用[UIColor whiteColor]。替换您自己选择的颜色。在passcodePopover的viewdidLoad方法中,您将希望使用此代码
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:textTitleOptions];
如果您的popover中没有navigationController,则必须稍微更改代码,而且您可能不想使用[UIColor whiteColor]。替换您自己选择的颜色。在passcodePopover的viewdidLoad方法中,您将希望使用此代码
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:textTitleOptions];
如果您的popover中没有navigationController,则必须稍微更改代码,而且您可能不想使用[UIColor whiteColor]。替换您自己选择的颜色。在viewdid Load函数中使用以下代码
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
[[UINavigationBar appearance]setTintColor:NavigationColor];
} else
{
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
}
if(楼层(NSFoundationVersionNumber)在viewdid加载功能中使用以下代码
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
[[UINavigationBar appearance]setTintColor:NavigationColor];
} else
{
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
}
if(楼层(NSFoundationVersionNumber)在viewdid加载功能中使用以下代码
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
[[UINavigationBar appearance]setTintColor:NavigationColor];
} else
{
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
}
if(楼层(NSFoundationVersionNumber)在viewdid加载功能中使用以下代码
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
[[UINavigationBar appearance]setTintColor:NavigationColor];
} else
{
[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
}
if(floor(NSFoundationVersionNumber)改为创建一个类别:
@implementation UINavigationBar (custom)
- (void)setCustomNavigationBar: (NSString *)_strTitle
{
[self setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
UILabel *_lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
_lblTitle.text = _strTitle;
_lblTitle.textAlignment = NSTextAlignmentCenter;
[_lblTitle setBackgroundColor:[UIColor clearColor]];
[_lblTitle setFont:[UIFont fontWithName:kAppFontBold size:kAppFontBoldSize]];
[_lblTitle setTextColor:[UIColor navigationBarColor]];
[[self topItem] setTitleView:_lblTitle];
}
其中kAppFontBold
和kAppFontBoldSize
是宏。创建一个类别:
@implementation UINavigationBar (custom)
- (void)setCustomNavigationBar: (NSString *)_strTitle
{
[self setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
UILabel *_lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
_lblTitle.text = _strTitle;
_lblTitle.textAlignment = NSTextAlignmentCenter;
[_lblTitle setBackgroundColor:[UIColor clearColor]];
[_lblTitle setFont:[UIFont fontWithName:kAppFontBold size:kAppFontBoldSize]];
[_lblTitle setTextColor:[UIColor navigationBarColor]];
[[self topItem] setTitleView:_lblTitle];
}
其中kAppFontBold
和kAppFontBoldSize
是宏。创建一个类别:
@implementation UINavigationBar (custom)
- (void)setCustomNavigationBar: (NSString *)_strTitle
{
[self setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
UILabel *_lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
_lblTitle.text = _strTitle;
_lblTitle.textAlignment = NSTextAlignmentCenter;
[_lblTitle setBackgroundColor:[UIColor clearColor]];
[_lblTitle setFont:[UIFont fontWithName:kAppFontBold size:kAppFontBoldSize]];
[_lblTitle setTextColor:[UIColor navigationBarColor]];
[[self topItem] setTitleView:_lblTitle];
}
其中kAppFontBold
和kAppFontBoldSize
是宏。创建一个类别:
@implementation UINavigationBar (custom)
- (void)setCustomNavigationBar: (NSString *)_strTitle
{
[self setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
UILabel *_lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
_lblTitle.text = _strTitle;
_lblTitle.textAlignment = NSTextAlignmentCenter;
[_lblTitle setBackgroundColor:[UIColor clearColor]];
[_lblTitle setFont:[UIFont fontWithName:kAppFontBold size:kAppFontBoldSize]];
[_lblTitle setTextColor:[UIColor navigationBarColor]];
[[self topItem] setTitleView:_lblTitle];
}
其中kAppFontBold
和kAppFontBoldSize
是宏。您可以使用它。它可能会对您有所帮助。.这里我为两种状态设置了字体和文本颜色
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor darkGrayColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
注意:setTitleTextAttributes:
方法仅适用于ios5.0+。您可以使用此方法。它可能会对您有所帮助。.这里我为两种状态设置了字体和文本颜色
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor darkGrayColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
NSForegroundColorAttributeName,[UIColor whiteColor],
NSForegroundColorAttributeName,[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
NSForegroundColorAttributeName,[UIFont fontWithName:@"Arial-Bold" size:0.0],
NSFontAttributeName,nil]];
注意:setTitleTextAttributes:
方法仅适用于ios5.0+。您可以使用此方法。它可能会对您有所帮助。.这里我为两种状态设置了字体和文本颜色
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor darkGrayColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
NSForegroundColorAttributeName,[UIColor whiteColor],
NSForegroundColorAttributeName,[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
NSForegroundColorAttributeName,[UIFont fontWithName:@"Arial-Bold" size:0.0],
NSFontAttributeName,nil]];
注意:setTitleTextAttributes:
方法仅适用于ios5.0+。您可以使用此方法。它可能会对您有所帮助。.这里我为两种状态设置了字体和文本颜色
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor darkGrayColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
[barItemForIndex setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:Tabbar_Item_Font_Size], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
NSForegroundColorAttributeName,[UIColor whiteColor],
NSForegroundColorAttributeName,[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
NSForegroundColorAttributeName,[UIFont fontWithName:@"Arial-Bold" size:0.0],
NSFontAttributeName,nil]];
注意:setTitleTextAttributes:
方法仅适用于ios5.0+。我发现根本原因,当出现viewcontroller时,将更改应用程序的色调属性。不知道我是如何找到根本原因的,当出现viewcontroller时,将更改应用程序的色调属性。不知道我是如何找到根本原因的viewcontroller将更改应用程序的tint属性。不知道我找到的根本原因是什么,当出现viewcontroller时,将更改应用程序的tint属性。不知道用于检查操作系统版本的技术取决于您的目标平台,如下所示:要在运行时检查iOS版本,请使用如下代码:NSString*osVersion=[[UIDevice currentDevice]系统版本];
若要在运行时检查OS X的版本,请使用格式塔函数和系统版本选择器常量。用于检查操作系统版本的技术取决于您的目标平台,如下所示:若要在运行时检查iOS的版本,请使用以下代码:NSString*osVersion=[[UIDevice currentDevice]systemVersion];
要在运行时检查OS X的版本,请使用格式塔函数和系统版本选择器常量。检查操作系统版本的技术取决于您的目标平台,如下所示:要在运行时检查iOS的版本,请使用如下代码:NSString*osVersion=[[UIDevice currentDevice]系统版本];
若要在运行时检查OS X的版本,请使用格式塔函数和系统版本选择器常量。用于检查操作系统版本的技术取决于您的目标平台,如下所示:若要在运行时检查iOS的版本,请使用以下代码:NSString*osVersion=[[UIDevice currentDevice]systemVersion];
要在运行时检查OS X的版本,请使用格式塔函数和系统版本选择器常量。
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],
NSForegroundColorAttributeName,[UIColor whiteColor],
NSForegroundColorAttributeName,[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
NSForegroundColorAttributeName,[UIFont fontWithName:@"Arial-Bold" size:0.0],
NSFontAttributeName,nil]];