2014-09-25 4 views
2

У меня есть UISearchbar в xib, а местозаполнитель не расположен в отличном дизайне.UISearchbar placeholder dislocated

См изображения enter image description here

+0

у были добавить uisearchbar в progrmatically или с помощью метода инструмента –

ответ

3
UITextField *txtField = [UITextField appearanceWhenContainedIn:[UISearchBar class], nil]; 
    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 8, 20)]; 
    paddingView.backgroundColor = [UIColor grayColor]; 
    [txtField setLeftViewMode:UITextFieldViewModeAlways]; 
    [txtField setLeftView:paddingView]; 
    txtField.delegate = self; 
    [txtField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; 
    txtField.textAlignment = UITextAlignmentLeft;