2013-06-18 45 views
0

我正在尋找具有左側按鈕的UiSearchBar。 我一直在閱讀this topic,並按照KennyTM描述的步驟,但我沒有設法得到相同的結果。用左鍵單擊的UISearchBar

這裏是我的本錢:

enter image description here

正如你可以看到我的搜索欄不具有相同的顏色比我的導航欄。

有沒有人有解決這個問題?

回答

0
for(id view in search.subviews) { 
     if([view isKindOfClass:[UIImageView class]]) { 
      UIImageView *img = (UIImageView *)view; 
      img.image = nil; 
     } 
    } 
search.backgroundImage = [UIImage imageNamed:@"searchbar.png"]; 

搜索是UISearchbar

+0

使用'search.backgroundImage = [UIColor clearColor];' – zbMax

0
/ button 
UIBarButtonItem *settingsButtonItem = // create settings button 

// search bar 
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 260, 44)]; 
UIBarButtonItem *searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar]; 
[searchBar release]; 

// toolbar is UIToolbar 
[toolbar setItems:[NSArray arrayWithObjects:settingsButtonItem, searchBarButtonItem nil] animated:NO]; 

請執行上面的代碼可以幫助它很多的對象。

+0

正常工作對不起,但試圖實現您的解決方案(這不幸導致這個問題的問題:http://stackoverflow.com/questions/ 3482612 /添加按鈕到左側的uisearchbar),我一直在撤消修改和獲得所需的結果。但感謝您的幫助。 – zbMax