println(\(UIApplication.sharedApplication().statusBarOrientation))
将(枚举值)打印到控制台。我可以打印有意义的statusBarOrientation属性版本而无需借助
if UIApplication.sharedApplication().statusBarOrientation == .Portrait
等?
答案 0 :(得分:2)
您可以添加符合UIInterfaceOrientation
到Printable
协议的扩展程序。
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)