ios - 如何快速转换NSValue中的CGPoint?

标签 ios swift cgpoint nsvalue

正如我的问题标题所述,我如何将 CGPoint 转换为 NSValues 以便我可以将其存储到 swift 中的数组中。

在 objective-C 中我们可以这样做:

  // CGPoint converted to NSValue
     CGPoint point = CGPointMake(9, 9);
     NSValue *pointObj = [NSValue valueWithCGPoint:point];

但是谁能告诉我如何快速完成此操作?

提前致谢。

最佳答案

尝试这样的事情:

let point = CGPointMake(9, 9)
var pointObj = NSValue(CGPoint: point)

关于ios - 如何快速转换NSValue中的CGPoint?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26251678/

相关文章:

iphone - 从 map 坐标获取 CGPoint 或从 MKMapPoint iphone 获取 CGPoint

ios - iOS SDK中如何计算cos、sin、tan?

ios - 多次使用同一个 View Controller

ios - 什么会导致 UIImageView 只显示/渲染加载图像的一半?

ios - 帮助循环、存储和使用 CGPoints

ios - 如何检查一个 View 是否在另一个 View 之上?

ios - 为 iPad 添加第二个启动画面

swift - 在 Swift 4/MacOS 中从 NSSlider 检测 mouseUp 事件

ios - 将单元格高度固定到 UICollectionView 高度

swift - iOS13 中 FCM 的推送通知问题