The title is the error message that I receive compiling this line:
let width : Float = mainView.frame.size.width / 100.0 * value
The value
variable is of Float
type. What's wrong here?
cannot invoke * with an argument list of type ($T12, @lvalue CGFloat)
Read answer in error:
mainView.frame.size.width
has type CGFloat
therefore you need cast CGFloat
to Float
Try to set value
as CGFloat
or cast Float(image.size.width)
In playground
Option 1
let image = UIImage(named:"group_1.png") // just for example
let value:CGFloat = 10.0
let width:Float = Float(image.size.width / 100.0 * value)
Option 2
let value:Float = 10.0
let width:Float = Float(image.size.width) / 100.0 * value
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