Here i am using these two functions draw circle in uiview
-(void)DrawLine:(CGContextRef)pDC :(int)x1 :(int)y1 :(int)x2 :(int)y2 :(CGColorRef)color{ int x,y; if ( abs(x2-x1) < abs(y2-y1) ) { for ( y=y1; (y2 > y1) ? y<=y2 : y>=y2; y+=((y2 > y1) ? +1 : -1) ) { x = (x2!=x1) ? (x1 - (x1-x2)/(y1-y2)(y1-y)) : x1; CGContextSetStrokeColorWithColor(pDC, color); CGRect dotRect = CGRectMake(x, y,0.5, 0.5); CGContextAddEllipseInRect(pDC, dotRect); CGContextDrawPath(pDC, kCGPathFillStroke); } } else { for ( x=x1; (x2 > x1) ? x<=x2 : x>=x2; x+=((x2 > x1) ? +1 : -1) ) { y = (y2!=y1) ? (y1 - (y1-y2)/(x1-x2)(x1-x)) : y1; CGContextSetStrokeColorWithColor(pDC, color); CGRect dotRect = CGRectMake(x, y,0.5, 0.5); CGContextAddEllipseInRect(pDC, dotRect); CGContextDrawPath(pDC, kCGPathFillStroke); } } }
-(void)DrawCircle:(CGContextRef)pDC :(CGPoint)p :(long)lRadius :(CGColorRef)color{ long i, x0,y0,x1,y1; double Weight; for ( i=0; i<360; i++ ) { Weight = 0.5*(cos(lightdir - ((double)i-180)/360*2*M_PI)+1.0);
x0 = lRadius * cos(2*M_PI*(i-180)/360);
y0 = lRadius * sin(2*M_PI*(i-180)/360);
x1 = lRadius * cos(2*M_PI*(i+1-180)/360);
y1 = lRadius * sin(2*M_PI*(i+1-180)/360);
[self DrawLine:pDC :p.x+x0 :p.y+y0 :p.x+x1 :p.y+y1 :color];
}
}
(void)drawRect:(CGRect)rect { touchAppDelegate app=(touchAppDelegate)[[UIApplication sharedApplication]delegate]; if(isFirstTime) { // Get the vital statistics of the window m_ptCenter.x=160; m_ptCenter.y=230; m_nRadius = 55; isFirstTime=NO; app.displayString=@""; textArea.text=@""; disString=app.displayString;
} disString=app.displayString;
CGContextRef contextRef = UIGraphicsGetCurrentContext();
//CGContextShowTextAtPoint(contextRef, 0, 0,string, 4);
//CGContextSetRGBFillColor(contextRef, 0, 255, 0, 0.1); //CGContextSetRGBStrokeColor(contextRef, 0, 0,255, 0.5); /CGColorSpaceRef colorspace=CGColorSpaceCreateDeviceRGB(); CGFloat values[4]={1.0,0.0,0.0,1.0}; CGColorRef color=CGColorCreate(colorspace, values); CGColorSpaceRelease(colorspace);/ int nRadius = m_nRadius; nRadius-=21; [self DrawCircle:contextRef :m_ptCenter :nRadius-- :[UIColor grayColor].CGColor]; nRadius+=46; [self DrawCircle:contextRef :m_ptCenter :nRadius-- :[UIColor grayColor].CGColor]; const CGPoint ptKnobCenter =[self CalculateKnobPosi:m_nKnobPosi]; int nKnobRadius = m_nKnobRadius;
/*if(m_bDragging) { [self DrawCircle:contextRef :ptKnobCenter :--nKnobRadius :[UIColor whiteColor].CGColor]; } else { [self DrawCircle:contextRef :ptKnobCenter :--nKnobRadius :[UIColor whiteColor].CGColor]; }*/ [self DrawCircle:contextRef :ptKnobCenter :--nKnobRadius :[UIColor whiteColor].CGColor];
}
In simulator its work well When i run this code in iphone its get some seconds to update uiview in iphone.....
Can anyone help me ?..... How can i fix this