我在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];]
Run Code Online (Sandbox Code Playgroud)
虽然自定义视图不坚持,但我没有看到任何明显简单的方法来获取默认按钮内的实际文本并开始更改其样式.