gpt4 book ai didi

ios - 快速更改方向时如何显示 View ?

转载 作者:搜寻专家 更新时间:2023-11-01 07:26:43 25 4
gpt4 key购买 nike

<分区>

我想在纵向模式下显示一个 View ,在横向模式下显示另一个 View 。是否可以?我试过这段代码,但 View 重叠。如何解决?

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
let app = UIApplication.sharedApplication()

if (app.statusBarOrientation.isLandscape)

var imageView : UIImageView
imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 1300
, height: 50))
imageView.contentMode = UIViewContentMode.ScaleToFill
// UIGraphicsBeginImageContext(self.view.frame.size)
imageView.image = UIImage(named:"Header")
self.view.addSubview(imageView)

UIGraphicsBeginImageContext(self.view.frame.size)
UIImage(named: "Landscape")?.drawInRect(self.view.bounds)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.view.backgroundColor = UIColor(patternImage: image)
display1()

if (app.statusBarOrientation.isPortrait)

var imageView : UIImageView
imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 800
, height: 50))
imageView.contentMode = UIViewContentMode.ScaleToFill
// UIGraphicsBeginImageContext(self.view.frame.size)
imageView.image = UIImage(named:"Header")
self.view.addSubview(imageView)

UIGraphicsBeginImageContext(self.view.frame.size)
UIImage(named: "background")?.drawInRect(self.view.bounds)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.view.backgroundColor = UIColor(patternImage: image)
print(String.self, "sandeep potrait")
displayKeyboard()

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