- drawRect not responding
- -(void)prepareVertex:(int)noOfVertex
- {
- polygonPoint=[NSMutableArray arrayWithCapacity:noOfVertex];
- for(int i=0;i<noOfVertex;i++)
- {
- CGPoint point=CGPointMake(sin((2*M_PI)*i/noOfVertex),(cos(2*M_PI)*i/noOfVertex));
- [polygonPoint addObject:[NSValue valueWithCGPoint:point]];
- NSValue *tempVal=[polygonPoint objectAtIndex:i];
- CGPoint tempPoint=[tempVal CGPointValue];
- NSLog(@"%f,%f",tempPoint.x,tempPoint.y);
- }
- }
- - (void)drawRect:(CGRect)rect
- {
- [self prepareVertex:5];
- for (int i=0; i<5; i++) {
- NSValue *tempVal=[polygonPoint objectAtIndex:i];
- CGPoint tempPoint=[tempVal CGPointValue];
- }
- CGContextRef context=UIGraphicsGetCurrentContext();
- CGContextSetLineWidth(context, 5);
- CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
- CGContextMoveToPoint(context, [[polygonPoint objectAtIndex:0] CGPointValue].x, [[polygonPoint objectAtIndex:0] CGPointValue].x);
- for (int i=1; i<5; i++) {
- CGPoint point=[[polygonPoint objectAtIndex:i] CGPointValue];
- CGContextAddLineToPoint(context,point.x, point.y);
- }
- CGContextStrokePath(context);
- }
- - (void)drawRect:(CGRect)rect {
- [self prepareVertex:5];
- CGContextRef context=UIGraphicsGetCurrentContext();
- CGContextSetLineWidth(context, 5);
- CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
- CGFloat x = self.center.x + self.bounds.size.width * 0.5 * [[polygonPoint objectAtIndex:0] CGPointValue].x;
- CGFloat y = self.center.y + self.bounds.size.height * 0.5 * [[polygonPoint objectAtIndex:0] CGPointValue].y;
- NSLog(@"Point %f/%f", x, y);
- CGContextMoveToPoint(context, x, y);
- for (int i=1; i<5; i++) {
- CGPoint point=[[polygonPoint objectAtIndex:i] CGPointValue];
- x = self.center.x + self.bounds.size.width * 0.5 * point.x;
- y = self.center.y + self.bounds.size.height * 0.5 * point.y;
- NSLog(@"Point %f/%f", x, y);
- CGContextAddLineToPoint(context, x, y);
- };
- CGContextStrokePath(context);
- }
- CGPoint point=CGPointMake(sin((2*M_PI)*i/noOfVertex),(cos(2*M_PI)*i/noOfVertex));
- CGFloat x = centerPoint.x + radius * sin(2*M_PI*i/noOfVertex);
- CGFloat y = centerPoint.y + radius * cos(2*M_PI*i/noOfVertex);
- CGPoint point = CGPointMake(x, y);