[背景]
swift中,如下代码:
let rect:CGRect=CGRectMake(0,0,floorf(self.view.bounds.size.width / count),self.tabBarHeight)
出错:
swift:123:79: Binary operator ‘/’ cannot be applied to operands of type ‘CGFloat’ and ‘Int’

[解决过程]
1.搜:
Binary operator / cannot be applied to operands of type CGFloat and Int
参考:
感觉是:
直接给int加上CGFloat应该就可以了:
let rect:CGRect=CGRectMake(0,0,floorf(self.view.bounds.size.width/CGFloat(count)),self.tabBarHeight)
结果出错:
Cannot convert value of type ‘CGFloat’ to expected argument type ‘Float’
那就再去解决:
转载请注明:在路上 » [已解决]Swift代码出错:Binary operator / cannot be applied to operands of type CGFloat and Int