statusBarOrientation返回(枚举值)

时间:2014-10-03 05:31:02

标签: ios swift xcode6

println(\(UIApplication.sharedApplication().statusBarOrientation))

将(枚举值)打印到控制台。我可以打印有意义的statusBarOrientation属性版本而无需借助

if UIApplication.sharedApplication().statusBarOrientation == .Portrait

等?

1 个答案:

答案 0 :(得分:2)

您可以添加符合UIInterfaceOrientationPrintable协议的扩展程序。

extension UIInterfaceOrientation: Printable {
    public var description: String {
        switch self {
        case Unknown:
            return "Unknown"
        case Portrait:
            return "Portrait"
        case PortraitUpsideDown:
            return "PortraitUpsideDown"
        case LandscapeLeft:
            return "LandscapeLeft"
        case LandscapeRight:
            return "LandscapeRight"
            }
    }
}

然后你可以:

println(UIApplication.sharedApplication().statusBarOrientation)