Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot invoke * with an argument list of type ($T12, @lvalue CGFloat)

Tags:

ios

swift

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?

like image 284
Andrey Chernukha Avatar asked Sep 22 '14 12:09

Andrey Chernukha


1 Answers

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
like image 117
Maxim Shoustin Avatar answered Nov 05 '22 21:11

Maxim Shoustin