1
我在UIBarButtonItem中只有一個按鈕和一個圖像。我想將它放在屏幕中間,但無法調整框架。請參閱代碼,任何線索都會有用。UIBarButtonItem中的按鈕框架
- (void)viewDidLoad {
//self.navigationItem.hidesBackButton = NO;
[super viewDidLoad];
UIImage *emailImage = [UIImage imageNamed:@"Email_Button.png"];
UIButton *emailButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
emailButton.frame = CGRectMake(0, 0, 100, 30);
[emailButton setImage:emailImage forState:UIControlStateNormal];
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:emailButton];
//[aBarButtonItem setFrame:CGRectMake(100, 0, 100, 30)];
[emailButton addTarget:self action:@selector(sendEmail) forControlEvents:UIControlEventTouchUpInside];
NSMutableArray * arr = [NSMutableArray arrayWithObjects:aBarButtonItem, nil];
[[self navigationController] setToolbarHidden: NO animated:YES];
[self setToolbarItems:arr animated:YES];
}
謝謝
完美工作。謝謝。 – curious123