Cannot call * with a list of arguments of type ($ T12, @lvalue CGFloat)

The header is the error message I get to compile this line:

let width : Float = mainView.frame.size.width / 100.0 * value 

The variable value is of type Float . What is wrong here?

+7
ios swift
source share
1 answer

cannot call * using an argument list of type ($ T12, @lvalue CGFloat)

Read the answer by mistake:

mainView.frame.size.width is of type CGFloat , so you need to add CGFloat to Float

Try setting value as CGFloat or pour Float(image.size.width)


In the 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 
+12
source share

All Articles