解决方法
cannot invoke * with an argument list of type ($T12,@lvalue CGFloat)
阅读错误答案:
mainView.frame.size.width的类型为CGFloat,因此需要将CGFloat转换为Float
尝试将值设置为CGFloat或cast Float(image.size.width)
在操场上
选项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)
选项2
let value:Float = 10.0 let width:Float = Float(image.size.width) / 100.0 * value