gpt4 book ai didi

swift - 将旋转应用于弹出窗口

转载 作者:行者123 更新时间:2023-11-30 10:28:57 26 4
gpt4 key购买 nike

我正在使用 PopupDialog,它是 UIViewController 的子类,并且希望在弹出窗口时强制旋转此 View 。

这是我想做的一个例子:

import UIKit
import PopupDialog

class TestViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

}
func presentpopup() {
let popup = PopupDialog(title: "Title", message: "My message", image: nil)
let buttonOne = CancelButton(title: "cancel") {}
let buttonTwo = DefaultButton(title: "go to settings", dismissOnTap: false){
print("pressed")
}
//****** Here is where I would like to rotate the entire view***/////
popup.addButtons([buttonOne, buttonTwo])
self.present(popup, animated: true, completion: nil)
}

}

我想要的是类似于popup.rotate(.pi/2)的东西。这可能吗?我似乎不知道怎么办。

最佳答案

popup.view.transform = CGAffineTransform(rotationAngle: -.pi/2)

这会将 View 旋转 90 度。它可以应用于任何 View 。

关于swift - 将旋转应用于弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59557436/

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