【发布时间】:2014-11-19 19:43:46
【问题描述】:
我在 xib 中有一个 UISearchbar,而占位符不在完美的设计中。
见图片
【问题讨论】:
-
你是在程序中添加 uisearchbar 或使用工具方法
标签: ios uisearchbar placeholder
我在 xib 中有一个 UISearchbar,而占位符不在完美的设计中。
见图片
【问题讨论】:
标签: ios uisearchbar placeholder
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;
【讨论】: