【问题标题】:UISearchbar placeholder dislocatedUISearchbar 占位符错位
【发布时间】:2014-11-19 19:43:46
【问题描述】:

我在 xib 中有一个 UISearchbar,而占位符不在完美的设计中。

见图片

【问题讨论】:

  • 你是在程序中添加 uisearchbar 或使用工具方法

标签: ios uisearchbar placeholder


【解决方案1】:
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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-03
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多