Anybody knows what this doesn't work (Static member min cannot be used on instance of Type CGFloat. in the extension.
extension CGFloat {
mutating func normalize() {
self = min(max(CGFloat(0), self), CGFloat(1))
}
}
while this works
let f: CGFloat = CGFloat(0.4)
let maxValue = max(f, 1)
You can get this to work by specifying Swift.min and Swift.max as such:
extension CGFloat {
mutating func normalize() {
self = Swift.min( Swift.max(CGFloat(0), self), CGFloat(1))
}
}
when using just min and max it is unsure if you mean CGFloat.min or Swift.min
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With