i try to draw arc in view i use this code.
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect = CGRectMake(0,0,340,480);
UIView *ui = [[UIView alloc] initWithFrame:rect];
[self.view addSubview:ui];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddArc(context, 50, 50, 20, 0, 30, 0);
//set the fill or stroke color
CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1.0);
CGContextSetRGBStrokeColor(context, 0.5, 0.5, 0.5, 1.0);
//fill or draw the path
CGContextDrawPath(context, kCGPathStroke);
CGContextDrawPath(context, kCGPathFill);
}
if possible to draw arc in viewdidload method kindly guide me.
It is not possible to draw an arc in view Did Load.
What you need to do is:-
1.)Add a file of type
UIView(lets sayArcView.handArcView.m)in your project2.)In
ArcView.mfile implement- (void)drawRect:(CGRect)rectmethod3.)In this method you need to write your logic of drawing an arc or whatever you want to draw)
4.)Now the
ViewControllerin which you have to show your arc lets say(ArcViewControlleris the file in which you want to show your arc)5.)In
ArcViewController.mfile you need to do following steps:-a.)
#import "ArcView.h"b.)Whenever you want to show your arc view do:-
After that you will see your arc coming on your screen.