Reputation: 105
I don't know what the frame is exactly, but I can build
override public var intrinsicContentSize: CGSize {
let buttonSize = Int(frame.size.height)
let width = (buttonSize * starCount) + (spacing * (starCount-1))
return CGSize(width: width, height: buttonSize)
}
But I can't build
class RatingControl: UIView {
// MARK: Properties
let spacing = 5
let starCount = 5
let buttonSize = Int(frame.size.height)
.....
}
this code and error says "Value of type '(UIView) -> (CGRect) -> CGRect' has no member 'size'"
Why this happens?
Thanks in advance.
Upvotes: 1
Views: 4111
Reputation: 12910
It's because you haven't declared the frame
variable in some method.
Or better, as I see, that you extend UIView, you should use something like:
let buttonSize = Int(self.frame.size.height)
... or check what is that frame
variable supposed to be, using
print(frame)
right before let buttonSize ...
line
Upvotes: 5