最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]Swift代码出错:Binary operator / cannot be applied to operands of type CGFloat and Int

Swift crifan 7222浏览 0评论
[背景]
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’
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

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.437 seconds, using 22.10MB memory