1
我在左上角的導航欄中添加了2個帶有圖像的按鈕。但我的風格遇到問題。這是我的按鈕截圖。這是我在應用程序中編寫的按鈕代碼。如何在iPhone中的左導航欄按鈕中提供樣式
UIView *viewButtons = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 32)];
UIButton *button1 = [[UIButton alloc] init];
button1.frame=CGRectMake(0,0,40,35);
[button1 setBackgroundImage:[UIImage imageNamed: @"remainder.png"] forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(sortByremainder) forControlEvents:UIControlEventTouchUpInside];
[viewButtons addSubview:button1];
UIButton *button2 = [[UIButton alloc] init];
button2.frame=CGRectMake(45,0,60,35);
[button2 setBackgroundImage:[UIImage imageNamed: @"like_symbol.jpg"] forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(sortByMostFaved) forControlEvents:UIControlEventTouchUpInside];
[viewButtons addSubview:button1];
[viewButtons addSubview:button2];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:viewButtons];
[viewButtons release];
但我想我的按鈕樣式應該是這樣的形象。我想保持按鈕中的圖像,但在屏幕下方更具體的按鈕。它有邊界和凸面區域。
感謝advacnce
能UIBarButton與UIView的添加([viewButtons addSubview:按鈕1]; )? –
我不確定,但我不這麼認爲。但爲什麼你想將其添加到視圖? – Deeps