【问题标题】:In iOS UIAlertController, Can we left align text of UIAlertAction在 iOS UIAlertController 中,我们可以左对齐 UIAlertAction 的文本吗
【发布时间】:2017-01-05 21:36:32
【问题描述】:
我需要实现一个 UIAlertController,例如这个 UIAlertController 左对齐 UIAlertAction
在互联网和stackoverflow中搜索了很多之后,我能够实现UIAlertController的左对齐标题
但是如何左对齐 UIAlertAction 的文本呢?
任何帮助/线索都会非常有帮助。
【问题讨论】:
标签:
ios
text
alignment
uialertaction
【解决方案1】:
有人在以下位置发布了关于同一件事的更新问题:
UIAlertAction Text Styling.
我正在寻找同样的东西,根据我所学到的,您只能在 .alert 演示样式中使用 UIAlertController 时更改文本样式和对齐方式,但不能在与 UIAlertAction 一起使用时更改文本样式和对齐方式.actionSheet 演示风格的项目。
这里似乎只能使用提供自定义实现的库,例如XLActionController。
以.alert 演示样式整体修改 UIAlertController 的文本对齐方式,答案在:UIAlertController Text Styling。
我尝试对UIAlertAction 使用相同的方法,但这导致了一些Key-Value compliance / Undefined key 异常并且控制器不显示。
【解决方案2】:
是的,您可以,使用以下方法
[(your uialertaction object) setValue:@0 forKey:@"titleTextAlignment"]