UIAlertAction Value List

I am trying to figure out how to change the font type for the UIAlertAction header. I assume this can be done by setting a value for a particular key. For example, to set an image, you will do the following:

action.setValue(image, forKey: "image")

Is there a list of all available keys? I cannot figure out which key to use to change the font, align the title left / right, etc.

+6
source share
2 answers

You can use this to change the color of the UIAlertAction header.

 UIAlertController *alertController = [UIAlertController
                                          alertControllerWithTitle:@"alert view"
                                          message:@"hello alert controller"
                                          preferredStyle:UIAlertControllerStyleAlert];

    alertController.view.tintColor = [UIColor greenColor];

    UIAlertAction *cancelAction = [UIAlertAction
                                   actionWithTitle:@"Cancel"
                                   style:UIAlertActionStyleCancel
                                   handler:^(UIAlertAction *action)
                                   {

                                   }];
    [alertController addAction:cancelAction];

    [self.navigationController presentViewController: alertController animated:YES completion:nil];

OR

Check this link - custom font, size, color UIAlertController

0
source

class_copyIvarList maybe what you need.

swift

extension UIAlertAction {
    static var propertyNames: [String] {
        var outCount: UInt32 = 0
        guard let ivars = class_copyIvarList(self, &outCount) else {
            return []
        }
        var result = [String]()
        let count = Int(outCount)
        for i in 0..<count {
            let pro: Ivar = ivars[i]
            guard let ivarName = ivar_getName(pro) else {
                continue
            }
            guard let name = String(utf8String: ivarName) else {
                continue
            }
            result.append(name)
        }
        return result
    }
}

then

print(UIAlertAction.propertyNames)

and conclusion

["_title", "_titleTextAlignment", "_enabled", "_checked", "_isPreferred", "_imageTintColor", "_titleTextColor", "_style", "_handler", "_simpleHandler", "_image", "_shouldDismissHandler", "__descriptiveText", "_contentViewController", "_keyCommandInput", "_keyCommandModifierFlags", "__representer", "__interfaceActionRepresentation", "__alertController"]
0
source

All Articles