首页 文章

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

提问于
浏览
0

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

我的视图控制器代码 .

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 ! My project portrait must be portrait i want to change only this view orientation to landscape.

我也是我的项目导向

[x]肖像

[ ] 上下翻转

[]左侧风景

[]风景正确

1 回答

  • 1

    使用 :-

    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)
    
    
    }
    

相关问题