我正在创建自定义视图以生成导航栏项目。更改导航栏按钮文本颜色
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
UIView *backButtonView = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,35)];
UIButton *myBackButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[myBackButton setFrame:CGRectMake(0,0,70,35)];
myBackButton.titleLabel.text = @"Back";
myBackButton.backgroundColor = [UIColor yellowColor];
myBackButton.titleLabel.textAlignment = UITextAlignmentCenter;
myBackButton.titleLabel.textColor = [UIColor blackColor];
[myBackButton setEnabled:YES];
[myBackButton addTarget:self.navigationController action:@selector(moveBack:) forControlEvents:UIControlEventTouchUpInside];
[backButtonView addSubview:myBackButton];
[myBackButton release];
UIBarButtonItem* backButton = [[UIBarButtonItem alloc] initWithCustomView:backButtonView];
self.navigationItem.leftBarButtonItem = backButton;
[backButtonView release];
[backButton release];
CGRect frame = CGRectMake(300, 0, 400, 35);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor yellowColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor blackColor];
label.text = @"Order booking";
self.navigationItem.titleView = label;
}
return self;
}
有了这个,我有以下的输出:
我想栏按钮有相同的背景色导航栏及其在黑色文本。我曾尝试通过使用UINavigationController代表,但无法获得成功。 我需要做些什么改变?请协助。
Nitish
我在哪里可以下载或查看5.0 documention.may我安装这个在Xcode 3,请帮助me.where我可以下载WWDC.thanku所有新的示例代码。我等待乌拉圭回合早日答复 –
你可以在这里找到所有的会话(https://developer.apple.com/videos/wwdc/2011/)。会话114被称为“自定义UIKit控件的外观”。您需要使用Apple ID登录才能看到它。 – ettore
要编码iOS 5 SDK,您需要Xcode 4.2。目前,会话中有一些示例代码,但迄今为止,仅供WWDC与会者使用。我猜新版iOS 5 API的文档尚未完成,尚未发布。尽管如此,会话确实会引导您阅读大量代码。 –