使用CGSizeMake和CGSize有什么区别?这个比那个好吗? [英] What's the difference between using CGSizeMake and CGSize? Is one better than the other?
本文介绍了使用CGSizeMake和CGSize有什么区别?这个比那个好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CGSize(宽度:360,高度:480)
和 CGSizeMake(360,480)
似乎有同样的效果。对另一个人更喜欢吗?有什么区别?
CGSize(width: 360, height: 480)
and CGSizeMake(360, 480)
seem to have the same effect. Is one preferred to the other? What is the difference?
推荐答案
CGSize
构造函数是一个Swift扩展on CGSize
:
The CGSize
constructor is a Swift extension on CGSize
:
extension CGSize {
public static var zero: CGSize { get }
public init(width: Int, height: Int)
public init(width: Double, height: Double)
}
CGSizeMake
是一个从Objective-C桥接的剩余内联函数:
CGSizeMake
is a leftover inline function bridged from Objective-C:
/*** Definitions of inline functions. ***/
// ...
public func CGSizeMake(width: CGFloat, _ height: CGFloat) -> CGSize
两者在Swift中具有相同的功能, CGSize
构造函数比另一个更Swifty,并提供了方便。
Both have the same functionality in Swift, the CGSize
constructor is just more "Swifty" than the other and provided as a convenience.
这篇关于使用CGSizeMake和CGSize有什么区别?这个比那个好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文