【发布时间】:2011-07-20 16:36:17
【问题描述】:
我将以下代码用于导航栏中带有标题的自定义后退按钮。但是,标题没有显示,有什么帮助吗?
nb:后退按钮图片是黑色的,和ios默认使用的一样,需要自定义动作处理程序,这就是为什么这样做。
backButton=[UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:[UIImage imageNamed:@"backbutton.png"] forState:UIControlStateNormal];
[backButton setImage:[UIImage imageNamed:@"backbutton.png"] forState:UIControlStateSelected];
[backButton addTarget:self action:@selector(customBack) forControlEvents:UIControlEventTouchUpInside];
[backButton setFrame:CGRectMake(0,0,64,32)];
[backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[backButton setTitle:@"Encameo" forState:UIControlStateNormal];
[backButton setTitle:@"Encameo" forState:UIControlStateSelected];
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView: backButton];
【问题讨论】:
标签: ios uibutton uibarbuttonitem