我不知道框架到底是什么,但我可以建造
override public var intrinsicContentSize: CGSize {
let buttonSize = Int(frame.size.height)
let width = (buttonSize * starCount) + (spacing * (starCount-1))
return CGSize(width: width, height: buttonSize)
}
Run Code Online (Sandbox Code Playgroud)
但我不能建立
class RatingControl: UIView {
// MARK: Properties
let spacing = 5
let starCount = 5
let buttonSize = Int(frame.size.height)
.....
}
Run Code Online (Sandbox Code Playgroud)
此代码和错误表示“类型'(UIView)->(CGRect)-> CGRect'的值没有成员'大小'”
为什么会发生这种情况?
提前致谢。