DYPieChartView 0.0.4

DYPieChartView 0.0.4

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年1月

Dwarven维护。



使用自定义CALayer的动态饼图。

预览

lineWidth:默认为nil

Demo Gif

lineWidth:10

Demo Gif

Podfile

要使用CocoaPods将DYPieChartView集成到您的Xcode项目中,请在您的Podfile中指定它

pod 'DYPieChartView'

如何使用

#import "DYPieChartView.h"

#define MakeColor(r, g, b) [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]

#pragma mark - init and setup DYPieChartView
_pieChartView = [[DYPieChartView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
//_pieChartView.backgroundColor = [UIColor lightGrayColor];
_pieChartView.startAngle = -M_PI/2;
_pieChartView.clockwise = NO;
_pieChartView.lineWidth = @(10);
_pieChartView.center = self.view.center;
_pieChartView.sectorColors = @[MakeColor(120, 110, 230),
                               MakeColor(110, 240, 190),
                               MakeColor(10, 220, 230),
                               MakeColor(240, 140, 10),
                               MakeColor(230, 10, 100)];
[self.view addSubview:_pieChartView];

#pragma mark - animations
//type 1: for duration
[_pieChartView animateToScaleValues:@[@(0.4), @(0.35), @(0.25), @(0.0), @(0.0)]
                           duration:2];
//type 2: quickly
[_pieChartView setScaleValues:@[@(0.4), @(0.35), @(0.25), @(0.0), @(0.0)];