2011-01-22 3 views

답변

3

이 일을 할 수있는 API가 있습니다.

  1. MIMChart
  2. CorePlot 유효하지만 편리하지 라이브러리

    .
1

다른 사람의 코드처럼 보이는 경우, 웹 사이트에서 코드를 작성하는 방법과 iPhone을 시작한 후 오래 걸리지 않았다는 경고가 추가되었다는 경고와 함께 사용하면 도움이 될 수 있습니다. 어떤 비트가 비효율적이거나 잘못되었는지 알려주고 싶은 사람들은 환영 받고 있습니다. 나는 아직도 배우고 있습니다.

static inline float radians(double degrees) { return degrees * M_PI/180; } 

// making a simple pac man shape 
- (UIImage*)getImage { 

    UIImage* image; 
    if(self.completion == 100.0f) { 
     image = [UIImage imageNamed:@"completedTaskIcon.png"]; 
    } else { 
     UIGraphicsBeginImageContext(CGSizeMake(SIDELENGTH, SIDELENGTH)); 

     CGContextRef context = UIGraphicsGetCurrentContext(); 

     // the image should have a clear background 
     [[UIColor clearColor] set]; 
     CGRect myRect = CGRectMake(0.0f, 0.0f, SIDELENGTH, SIDELENGTH); 
     UIRectFill(myRect); 

     // color was hopefully set before this method called 
     [self.color set]; 

     // centre point is required 
     CGFloat midx = SIDELENGTH/2; 
     CGFloat midy = SIDELENGTH/2; 
     // radius of the arc 
     CGFloat radius = (SIDELENGTH/2) * 0.60f; 

     // pie background 
     CGContextSetFillColor(context, CGColorGetComponents([[UIColor orangeColor] CGColor])); 
     CGContextBeginPath(context); 
     CGContextMoveToPoint(context, midx + radius, midy); 
     CGContextAddArc(context, midx, midy, radius, radians(0), radians(360), 0); 
     CGContextFillPath(context); 

     // pie segment 
     CGContextSetFillColor(context, CGColorGetComponents([[UIColor blueColor] CGColor])); 
     CGContextBeginPath(context); 
     CGContextMoveToPoint(context, midx, midy); 
     CGContextAddLineToPoint(context, midx + radius, midy); 
     CGContextAddArc(context, midx, midy, radius, radians(0), radians(360 * (self.completion/100.0f)), 0); 
     CGContextFillPath(context); 
     image = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext(); 
    } 

    return image; 
} 
0

다른 답변에는 제안 된 라이브러리 외에도 실제로 사용한 두 가지 오픈 소스 원형 차트 클래스가 있습니다. 그들은 매우 간단 GitHub의에서 그들을 한 번 봐 가지고, 아주 예뻐요 :

당신이 내 대답을 참조 할 수 있습니다
관련 문제