In iOS UIAlertController, Can we left align text of UIAlertAction
Asked Answered
S

2

6

I Need to implement a UIAlertController such as this UIAlertController with left alligned UIAlertAction

description1

After searching quite a lot in the internet and here in stackoverflow, I was able to achieve left aligned title of UIAlertController

description2

But how to left align text of UIAlertAction ?

Any help/clue would be very helpful.

Septarium answered 29/8, 2016 at 18:58 Comment(3)
Possible duplicate of UIAlertController text alignmentBruce
github.com/wimagguc/ios-custom-alertview Use this github source.Burris
Any Success, i want to need this.Etymon
E
1

Yes you can, with the following

[(your uialertaction object) setValue:@0 forKey:@"titleTextAlignment"]
Eyebolt answered 9/2, 2018 at 12:41 Comment(0)
O
0

Someone posted a newer question regarding the same thing at:

UIAlertAction Text Styling.

I was searching for the same thing and from what I have learned, you can only change text styling and alignment when you're using a UIAlertController in the .alert presentation style, but not when you're using it with UIAlertAction items in .actionSheet presentation style.

Only recourse here seems to be using libraries that provide custom implementations such as XLActionController.

Modifying text alignment for the UIAlertController as a whole in .alert presentation style is answered at: UIAlertController Text Styling.

I tried to use the same method for UIAlertAction but that resulted in some Key-Value compliance / Undefined key exceptions and the controller not displaying.

Offutt answered 22/1, 2018 at 7:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.