我正在制作一个带有PNG的自定义backBarButtonItem
,并且工作得很好。唯一的问题是如何更改文本颜色。我在导航栏上的方式就是:
CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"aColor.png"]];
self.navigationItem.titleView = label;
label.text = @"aTitle";
答案 0 :(得分:1)
在将它们释放后,不要使用autorelease将set label设置为titleview
CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"aColor.png"]];
label.text = @"aTitle";
self.navigationItem.titleView = label;
[label release];