Andrey Chernukha
Andrey Chernukha

Reputation: 21808

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

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?

Upvotes: 8

Views: 14156

Answers (1)

Maxim Shoustin
Maxim Shoustin

Reputation: 77904

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

Upvotes: 12

Related Questions