Custom UISearchBar

deni2s, 28.02.2012., 01:22

 searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[searchBar setPlaceholder:@"Search in Plaza Lapiazza, Jakarta Raya, Indonesia"];

//to remove searchbar default background layer
if ([[[searchBar subviews] objectAtIndex:0] isKindOfClass:[UIImageView class]]){
[[[searchBar subviews] objectAtIndex:0] removeFromSuperview];
}

//to remove search icon. Note that objectAtIndex = 0 because background layer is already removed
UITextField *textField;
if ([[[searchBar subviews] objectAtIndex:0] isKindOfClass:[UITextField class]]){
textField = [[searchBar subviews] objectAtIndex:0];
}
textField.leftView = nil;

//to change textField Frame
UIImage *searchBarImage = [[UIImage imageNamed:@"search_bar_fit.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[textField setBackground:searchBarImage];

//to change textfield font and size
[textField setFont:[UIFontfontWithName:@"HelveticaNeue-Light" size:15]];

//to add transparent background on searchbar
[searchBar setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"search_bottom.png"]]];
[[searchBar layer] setOpaque:NO];

 

 

Izmantoju "Laimas svētki" appā. Info no ios.biomsoft.com/2011/12/07/some-ios-fevelopment-tricks/


0 komentāri Komentēšana pieejama visiem.
Komentāra pievienošana

Ar * atzīmētie lauciņi ir jāaizpilda obligāti.





atpakaļ uz ziņu sarakstu

Par web.hc.lv

web.hc.lv ir vortāls, kurā tiek aplūkoti mājaslapu veidošanas un mārketinga aspekti, no idejas līdz gandarījumam.

Reklāma
ienāktreģistrēties