我通過創建一個帶有自定義背景圖像的UIButton按照this Stackoverflow answer得到了這個工作。
在情況下,它可以幫助任何人,這裏是我的代碼:
#import <QuartzCore/QuartzCore.h>
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"mybackground.png"] forState:UIControlStateNormal];
[button setTitle:NSLocalizedString(@"Login", @"Button (9 chars limit) - Login") forState:UIControlStateNormal];
button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
[button.layer setCornerRadius:5.0f];
[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:1.0f];
[button.layer setBorderColor: [[UIColor grayColor] CGColor]];
button.frame=CGRectMake(0.0, 100.0, 60.0, 30.0);
[button addTarget:self action:@selector(myLoginActionMethod:) forControlEvents:UIControlEventTouchUpInside];
self._loginButton= [[UIBarButtonItem alloc] initWithCustomView:button];
在一般情況下,我認爲這是最好的設置色調在UIViewController中像這樣的(雖然我的情況,這並不因工作在drawRect
調酒在我的代碼在UINavigationBar
在到位):
self.navigationController.navigationBar.tintColor=[UIColor blueColor];
「我們支持的iOS 3.x客戶端」 –