Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertAction list of values

I'm trying to figure out how to change font type for UIAlertAction title. I'm assuming, it can be done by setting a value for particular key. For instance, to set an image you would do this:

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

Is there a list of all keys that are available? I can't figure out which key to use for changing font, aligning the title left/right, etc...

like image 369
dmitryame Avatar asked May 05 '15 14:05

dmitryame


1 Answers

class_copyIvarList may be 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 the output is

["_title", "_titleTextAlignment", "_enabled", "_checked", "_isPreferred", "_imageTintColor", "_titleTextColor", "_style", "_handler", "_simpleHandler", "_image", "_shouldDismissHandler", "__descriptiveText", "_contentViewController", "_keyCommandInput", "_keyCommandModifierFlags", "__representer", "__interfaceActionRepresentation", "__alertController"]
like image 174
Phecda.S Avatar answered Oct 16 '22 16:10

Phecda.S