2013-08-20 69 views
1

我試圖改變的UISearchBar的外觀,得到以下結果的UISearchBar完全自定義的背景

Custom Search Bar http://imageshack.com/a/img194/3835/jhl7.png

我試圖與UIAppearance方法,並且還通過移除UISearchBarBackground,但似乎邊界的文本字段不能被刪除。

我得到的最好的結果是:

actual search bar

的問題不是放大鏡,但邊界:)

+0

你可能會發布一些代碼嗎? –

+0

你的酒吧風格是什麼? – Kepler

+0

@KirillProkopovich:酒吧風格是默認的,改爲黑色或黑色半透明無論如何不會解決我的問題。 – LiohAu

回答

3

嘗試清除顏色設置爲您serch主頁吧:

[[UISearchBar appearance] setTintColor:[UIColor clearColor]]; 

或試試看:

UIImage *searchBg = [UIImage imageNamed:@"Search_Background.png"]; 
searchBg = [searchBg stretchableImageWithLeftCapWidth:10 topCapHeight:10]; //experiment with values 
[[UISearchBar appearance] setSearchFieldBackgroundImage: [[UIImage imageNamed: @"background-search"]; 
+0

不,它不起作用,這是我用清晰的顏色獲得:http://img43.imageshack.us/img43/6342/rcfr.png – LiohAu

+0

我編輯答案,檢查它。 – Kepler

+0

well setBackgroundImage本身並沒有解決問題,但這和ANDSelectFieldBackgroundImage工作的搜索欄。我現在必須檢查範圍。 – LiohAu