我正在尝试在我的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];
}
答案 0 :(得分:1)
您必须将此按钮设置为要显示的位置,例如
self.navigationItem.leftBarButtonItem = barbutton