简体   繁体   English

swift CGFloat到int xcode 6 beta 4

[英]swift CGFloat to int xcode 6 beta 4

var w:Int  = Int(self.bounds.size.width / Float(worldSize.width))
var h:Int  = Int(self.bounds.size.height / Float(worldSize.height))

Error : 'CGFloat is not convertible to UInt8' 错误:'CGFloat无法转换为UInt8'

I researched this conver type and i found this one Convert Float to Int in Swift my code like this but not working any idea ? 我研究了这个转换类型,我在Swift中找到了这个转换Float到Int我的代码,但是没有任何想法吗?

In beta 4, CGFloat has become a new type. 在beta 4中, CGFloat已成为一种新型。 So you'd do: 所以你要这样做:

var w:Int  = Int(self.bounds.size.width / CGFloat(worldSize.width))
var h:Int  = Int(self.bounds.size.height / CGFloat(worldSize.height))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM