我正在尝试添加一个 UIToolbar,以在 NavigationBar 中显示用户业力。我遇到的问题是颜色不完全相等,正如您在照片中看到的那样。
那么,任何想法我怎么能解决这个问题?这是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
UIToolbar *tools = [[UIToolbar alloc]
initWithFrame:CGRectMake(0.0f, 0.0f, 80.0f, 45.00f)];
UILabel *karma = [[UILabel alloc] initWithFrame:CGRectMake(30.0f, 0.0f, 40.0f, 44.00f)];
karma.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"karma"];
karma.font = [UIFont fontWithName:@"Helvetica" size:(14.0)];
karma.textColor = [UIColor colorWithRed:(255.0) green:(255.0) blue:(255.0) alpha:1];
karma.backgroundColor = [UIColor colorWithRed:(64/255.0) green:(64/255.0) blue:(64/255.0) alpha:0];
UIImage *image = [UIImage imageNamed:@"ic_people.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0.0f, 7.5f, 30.0f, 30.00f);
// Add Pin button.
[tools setBarStyle: UIBarStyleDefault];
[tools addSubview:karma];
[tools addSubview:imageView];
// Add toolbar to nav bar.
UIBarButtonItem *karmaNav = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = karmaNav;
...
谢谢你。