ios - Swift 3 - 方向改变时翻转整个屏幕/ View

标签 ios swift swift3

我需要一种方法来持续监控用户是否旋转了 iPad。

UserDidRotate() {

    if(orientation = portrait.upsideDown){

        //
        //Code that will Present View upside down...
        //
    }
        else if(orientation = portrait){

        //
        //Code that will Present View right side up...
        //
    }
}

如何检查方向变化并手动为我的 Swift 3 应用呈现上下颠倒的 View ?

编辑:

我已经尝试过:

override func viewWillTransition(to size: CGSize, with coordinator: 
UIViewControllerTransitionCoordinator){} 

并且该方法永远不会被命中。

最佳答案

尝试:

self.view.transform = self.view.transform.rotated(by: CGFloat(M_PI))

关于ios - Swift 3 - 方向改变时翻转整个屏幕/ View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43921630/

相关文章:

ios - 如何将 ImageView 转换并放大为形状(swift3)

ios - 如何检查 WKWebView URLAuthenticationChallenge 是否失败或成功?

swift - 如何在 SwiftUI 中使用 AudioKit?在 View 中更改状态变量

Swift - 使用未解析的标识符 'map'

ios - swift 3 : Caching images in a collectionView

ios - 如何为 pod 指定依赖项

ios - 带有 Alamofire post 参数的 SwiftyJSON 对象

ios - Swift3 中的 SKScene 和 URLQueryItems?

ios - 错误 "int1"无法转换为 'Bool' swift3

ios - writeCopy 后出现 RLMException "Realm at path ' ' already opened with different encryption key"(toFile :, 加密 key :)