简体   繁体   English

将UIAlertAction标题向左对齐

[英]Align UIAlertAction Title to the Left

I've been trying to align the title of an UIAlertAction item, but I can't seem to make it work. 我一直在尝试对齐UIAlertAction项目的标题,但似乎无法使它工作。

在此处输入图片说明

Do you guys have any idea how to make it work in Objective-C? 你们知道如何在Objective-C中使用它吗?

[alertAction setValue:[NSNumber numberWithInt:NSTextAlignmentLeft]
forKey:@"titleTextAlignment"];

UIAlertController is an opaque class. UIAlertController是一个不透明的类。 That kind of customization isn't supported. 不支持这种自定义。 If you want, you can try to roll your own, or find an open source alternative. 如果需要,您可以尝试自己动手,或找到开源替代方案。

I've tried hacking it by traversing the view hierarchy and finding labels, but it didn't seem to work. 我曾尝试通过遍历视图层次结构和查找标签来对其进行破解,但它似乎没有用。 I also tested with UIAppearance , but labels don't respond to alignment changes. 我还使用UIAppearance进行了UIAppearance ,但是标签不响应对齐方式更改。

My sample code (Swift) is on GitHub . 我的示例代码(Swift) 在GitHub上

Some open source alternatives: 一些开源替代品:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM