Mus*_*afa 6 iphone quartz-graphics nsmutablearray drawrect cgcontextref
我怎样才能将CGContextAddArc中的所有像素点到NSMutableArray.or CGContextRef到NSMutable Array
static inline float radians(double degrees)
{
return degrees * PI / 180;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect parentViewBounds = self.bounds;
CGFloat x = CGRectGetWidth(parentViewBounds)/2;
CGFloat y = CGRectGetHeight(parentViewBounds)/2;
UIColor *rbg=[UIColor redColor];
CGContextSetFillColor(context, CGColorGetComponents( [rbg CGColor]));
CGContextMoveToPoint(context, x, y);
CGContextAddArc(context, x, y,100,radians(35),radians(105),0);
CGContextClosePath(context);
CGContextFillPath(context);
// here I want to store All points Containing in the Arc to NSMutableArray
NSMutableArray *pointsArray=????
}
Run Code Online (Sandbox Code Playgroud)
图片
存储或当您想在 NSValue 中的 CGPoint 数组中添加点时,
NSValue *point = [NSValue valueWithCGPoint:CGPointMake(your_X, your_Y)];
[pointsArray addObject:point];
Run Code Online (Sandbox Code Playgroud)
现在在检索时,您将如何从数组中的 NSVaule stroe 读取 CGPoint,
NSValue *getPoint = [pointsArray objectAtIndex:i];
CGPoint thePoint = [getPoint CGPointValue];
Run Code Online (Sandbox Code Playgroud)
thePoint 将是您的答案。
| 归档时间: |
|
| 查看次数: |
1066 次 |
| 最近记录: |