CGRect和NSRect之间有什么区别吗? [英] Is there any difference between a CGRect and an NSRect?

查看:579
本文介绍了CGRect和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆