【发布时间】:2012-12-13 23:28:20
【问题描述】:
我在 UINavigationController 的导航栏上使用了自定义 tintColor,因为颜色太浅,我需要使用深色文本。更换标题视图和我在右侧添加的自定义按钮相对容易,但我似乎无法将自定义视图粘贴在后退按钮上。这就是我现在正在尝试的:
UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[backLabel setFont:[UIFont fontWithName:[[UIFont fontNamesForFamilyName:@"Arial Rounded MT Bold"] objectAtIndex:0] size:24.0]];
[backLabel setTextColor:[UIColor blackColor]];
[backLabel setShadowColor:[UIColor clearColor]];
[backLabel setText:[aCategory displayName]];
[backLabel sizeToFit];
[backLabel setBackgroundColor:[UIColor clearColor]];
UIBarButtonItem *temporaryBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:backLabel];
temporaryBarButtonItem.customView = backLabel;
[backLabel release];
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
[temporaryBarButtonItem release];]
自定义视图并没有坚持下去,而且我没有看到任何明显简单的方法来获取默认按钮内的实际文本并开始更改其样式。
【问题讨论】:
-
出于好奇:为什么这个问题是社区 wiki?
-
出于好奇:为什么每个答案社区都是 wiki?
标签: iphone cocoa-touch