Align UIAlertAction Title to the Left

2019-08-18 22:26发布

I've been trying to align the title of an UIAlertAction item, but I can't seem to make it work.

enter image description here

Do you guys have any idea how to make it work in Objective-C?

2条回答
男人必须洒脱
2楼-- · 2019-08-18 22:54

UIAlertController is an opaque class. 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.

My sample code (Swift) is on GitHub.

Some open source alternatives:

查看更多
【Aperson】
3楼-- · 2019-08-18 23:10
[alertAction setValue:[NSNumber numberWithInt:NSTextAlignmentLeft]
forKey:@"titleTextAlignment"];
查看更多
登录 后发表回答