簡體   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