请注意,我并没有尝试在 CGRect 中设置值。我很困惑为什么编译器会发出这个声明:
let widthFactor = 0.8
let oldWidth = wholeFrameView.frame.width
let newWidth = wholeFrameView.frame.width * widthFactor // Value of type '(CGRect) -> CGRect' has no member 'width'
let newWidth2 = wholeFrameView.frame.width * 0.8 // This is fine.
最佳答案
宽度是一个CGFloat
,其中您的乘数是一个Double
。显式声明乘数的类型:
let widthFactor: CGFloat = 0.8
关于ios - 为什么编译器声称 CGRect 没有宽度成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59384005/