Using Core Plot to show the selected Time Period in circle
I am developing an application in which I have to show the selected time in my clock image. Description:- What I exactly want to say it I am having a image of circle. Now according to t开发者_StackOverflow中文版he selected time I want that portion to be filled in some other color on my circle image. Please help me in doing this. I am stuck here.
I have attached the image that will describe more what I exactly want to do. I also tried it with doing it with pie-chart but area showing not giving proper time. Please please help me.
In this image it shows time 1:am to 6:am Any help would be highly appreciated.
For what you want above (not using coreplot). Place this code in the relevant drawRect/drawInContext method.
Not at mac so not 100% sure it will compile. Should be close. Also might be out by 90
#include <math.h>
CGFloat radius = 100;
//CGFloat pi = 3.1415927; //comes for free in math.h
//draw underlying circle;
UIBezierPath *basecircle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0,radius*2,radius*2)];
[[UIColor blackColor] set];
[basecircle fill];
CGFloat starttime = pi/6; //1 pm = 1/6 rad
GFloat endtime = pi; //6 pm = 1 rad
//draw arc
CGPoint center = CGPointMake(radius,radius);
UIBezier *arc = [UIBezierPath bezierPath]; //empty path
[arc moveToPoint:center];
CGPoint next;
next.x = radius + radius * sin(starttime);
next.y = radius + radius * cos(starttime);
[arc moveToPoint:next]; //go one end of arc
[arc addArcWithCenter:center radius:radius startAngle:starttime endAngle:endtime clockwise:YES]; //add the arc
[arc moveToPoint:center]; //back to center
[[UIColor yellowColor] set];
[arc fill];
精彩评论