gpt4 book ai didi

ios - 更新到最新的 Swift 版本问题

转载 作者:行者123 更新时间:2023-11-30 12:33:21 25 4
gpt4 key购买 nike

我刚刚更新到最新版本的 Swift,但遇到断点错误问题。控制台中没有错误。

backgroundsetting.innerColor = UIColor.rgb(fromHex: 0xB0E7D7)

backgroundsetting.outterColor = UIColor.rgb(fromHex: 0x005E7D)

backgroundsetting.frame = (frame: CGRect(x: self.view.frame.size.width * 0, y: self.view.frame.size.height * 0, width:self.view.frame.size.width, height: self.view.frame.size.height))
self.view.addSubview(backgroundsetting)

然后更新后它要我设置 backgroundsetting.frame as! CGRect当我打开应用程序的该部分时,它会使应用程序崩溃。为什么会出现这种情况?以下是之后的代码:

backgroundsetting.innerColor = UIColor.rgb(fromHex: 0xB0E7D7)

backgroundsetting.outterColor = UIColor.rgb(fromHex: 0x005E7D)

backgroundsetting.frame = (frame: CGRect(x: self.view.frame.size.width * 0, y: self.view.frame.size.height * 0, width:self.view.frame.size.width, height: self.view.frame.size.height)) as! CGRect
self.view.addSubview(backgroundsetting)

最佳答案

backgroundsetting.frame 属性是一种 CGRect 类型,为什么不创建这样的 CGRect:

backgroundsetting.frame = CGRect(x: self.view.frame.size.width * 0, y: self.view.frame.size.height * 0, width:self.view.frame.size.width, height: self.view.frame.size.height)

关于ios - 更新到最新的 Swift 版本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43175148/

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