开发者

Why can i use integers inside CGSizeMake and CGRectMake?

I use integers all the time in these two commands. 开发者_如何转开发It works fine and I suspect it's common to do this.

But technically, I believe they require CG Floats, not integers.

Why does it work, and it is wrong to do this? If so, how to easily convert an int into a cg float ?


Yes an int can be implicitly converted to a float (i.e. CGFloat). Which means that, if you call CGSizeMake(40, 50), the C compiler can recognize that a float is required and convert the generated code to CGSizeMake(40.0f, 50.0f) automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜