0

我做了一个NSMutableArray这样的存储一堆CGPoints

    safeZonePoints = [NSMutableArray array];
    [safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(234, 160)]];
    [safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(284, 210)]];
    [safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(334, 160)]];
    [safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(284, 10)]];
    [safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(234, 160)]];

现在我可以NSValue从数组中获取 s 了,但是如何将一个NSValueback转换为 sCGPoint呢?

4

1 回答 1

2

做这样的事情:

NSValue *cgpointObj = [NSValue valueWithCGPoint:CGPointMake(234, 160)];
CGPoint loc = cgpointObj.pointValue;

查看以下链接:CGPoint to NSValue and reverse

回答你的问题应该足够了。

于 2014-07-30T21:32:51.727 回答