【问题标题】:Right Align UISearchbar placeholder右对齐 UISearchbar 占位符
【发布时间】:2016-10-06 13:00:55
【问题描述】:

此代码曾经可以工作,但在 ios 10 之后它已停止运行:

UITextField *searchTextField = [_searchBar valueForKey:@"_searchField"];
searchTextField.textAlignment = NSTextAlignmentRight

我已尝试过段落和属性占位符,但占位符始终是左对齐的。该错误出现在 xcode 7 和 8 中。我该如何解决?

【问题讨论】:

标签: ios objective-c iphone uisearchbar ios10


【解决方案1】:

也许这很长一段时间,这里是解决方案

斯威夫特

searchBar.semanticContentAttribute = .forceRightToLeft

【讨论】:

    【解决方案2】:

    如果您需要进行此类自定义,请勿使用UISearchBar。您必须使用UITextFieldUIImageView 自己制作,并响应delegate 调用。

    【讨论】:

      猜你喜欢
      • 2013-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      • 2011-10-07
      • 2014-11-19
      • 2012-07-08
      相关资源
      最近更新 更多