0

我正在尝试在我的 ViewController 上为 i-phone 应用程序初始化一个 barbutton 项。

在实施中:

-(void)viewDidLoad
{
 UIButton *TakePhoto = [UIButton buttonWithType:UIButtonTypeCustom];

[TakePhoto setTitle:@"Take Photo" forState:UIControlStateNormal];
TakePhoto.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
[TakePhoto.layer setCornerRadius:4.0f];
[TakePhoto.layer setBorderWidth:1.0f];
[TakePhoto.layer setBorderColor: [[UIColor redColor] CGColor]];
TakePhoto.frame=CGRectMake(200, 100.0, 60.0, 30.0);
[TakePhoto addTarget:self action:@selector(takePicture) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* barbutton= [[UIBarButtonItem alloc] initWithCustomView:TakePhoto];
}
4

1 回答 1

1

您必须将此按钮设置在要显示的位置,例如

self.navigationItem.leftBarButtonItem = barbutton
于 2013-06-05T11:37:04.453 回答