繁体   English   中英

Swift如何在纵向设备方向内将视图转换为横向? 有可能的?

[英]Swift How can i convert view to landscape , inside portrait device orientation? It is possible?

如何在人像设备方向内将视图转换为横向

我的View控制器代码。

import UIKit

class SampleViewController: UIViewController {


    var commingtextview:String = ""


    @IBOutlet weak var textview: UITextView!


    override func viewDidLoad() {
        super.viewDidLoad()

        navigationController!.navigationBar.barTintColor = UIColorFromRGBs(0x000000)
        navigationController!.navigationBar.tintColor = UIColor.whiteColor();


       textview.text = self.commingtextview

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Important ! 我的项目肖像必须是肖像,我只想将此视图方向更改为横向。

还有我的项目方向

[x]肖像

[ ] 上下翻转

[]风景左

[]景观权

采用 :-

override func viewWillAppear(animated: Bool) {

    super.viewWillAppear(animated)


    self.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
  // Set whatever frame you want
  // self.view.frame = CGRectMake(xOrigin,yOrigin,Width,Height)


}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM