CGRect和NSRect之间有什么区别吗? [英] Is there any difference between a CGRect and an NSRect?
问题描述
CGRect
和 NSRect
之间有什么区别吗?特别是,我想知道原点的位置。有什么重要的区别我需要知道吗?
此链接有更多信息。在此复制以便快速参考:
是CoreGraphics等效于 NSRect
。
它们有意在内存中具有相同的布局。因此,允许通过执行以下操作将 NSRect
转换为 CGRect
:
CGRect cgrect = *(CGRect *)& nsrect;
CoreGraphics还提供了一个 CGRectMake()
函数它的工作原理与 NSMakeRect()
相同(注意在名称中动词和对象的反转),除了它返回一个 CGRect
。
Is there any difference between a CGRect
and an NSRect
? In particular, I'm wondering about the position of the origin. Are there any important differences I need to know about?
解决方案 They're the same. This link has more information. Copied here for quick reference:
CGRect
is the CoreGraphics equivalent of NSRect
.
They are deliberately made to have the same layout in memory. As such, it is allowed to convert an NSRect
to a CGRect
by doing this:
CGRect cgrect = *(CGRect *)&nsrect;
CoreGraphics also provides a CGRectMake()
function which works the same as NSMakeRect()
(note the reversal of verb and object in the names) except it returns a CGRect
.
这篇关于CGRect和NSRect之间有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!