I am trying to extract programmatically the names of the enum cases of UIBlurEffect.Style
which have a rawValue
of Int
not String
. The names in an array would be ["extraLight","light","dark","regular",...]
Doing print(UIBlurEffect.Style.systemChromeMaterialLight)
doesn't print systemChromeMaterialLight
instead it prints UIBlurEffectStyle
I tried also using Mirror
but this yields a name of __C.UIBlurEffectStyle
Example code of what I am trying to do:
let myStyles : [UIBlurEffect.Style] = [.light, .dark, .regular, .prominent]
for style in myStyles {
print(style) // does not work, produces "UIBlurEffectStyle"
myFunction(styleName: String(reflecting: style)) // does not work, produces "UIBlurEffectStyle"
myFunction(styleName: String(describing: style)) // does not work, produces "UIBlurEffectStyle"
myFunction(styleName: "\(style)") // does not work, produces "UIBlurEffectStyle"
}
I am using Swift 5, iOS 14, and Xcode 12.3
For reference, the enum is defined as follows by Apple:
extension UIBlurEffect {
@available(iOS 8.0, *)
public enum Style : Int {
case extraLight = 0
case light = 1
case dark = 2
@available(iOS 10.0, *)
case regular = 4
...