gpt4 book ai didi

ios - Swift 如何将 View 转换为横向、内部纵向设备方向?有可能的?

转载 作者:行者123 更新时间:2023-11-28 16:16:13 24 4
gpt4 key购买 nike

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

我的 View Controller 代码。

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


}

重要! 我的项目肖像必须是肖像我只想将这个 View 方向更改为横向。

也是我的项目方向

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


}

关于ios - Swift 如何将 View 转换为横向、内部纵向设备方向?有可能的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39054103/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com