1
我有一個自定義酒吧按鈕項目,我想輕推5個像素。我將如何處理下面的代碼。我試圖設置「y」點,但不斷收到語法錯誤。如何移動導航欄內的酒吧按鈕項目
[self.navigationController setNavigationBarHidden:NO animated:YES];
UIImage *image = [UIImage imageNamed:@"arrow_back.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationController.navigationBar addSubview:imageView];
[imageView release];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
[customBarItem release];
}
感謝您的幫助
哪裏是按鈕畫面申報?我沒有在上面的代碼中看到。可能是這個問題? –
你正在得到什麼語法錯誤? – Maulik