这是一个简单的项目,用于显示带可配置数字和颜色范围的外环圆形图表,带有背景透明度/颜色配置。包含演示项目。在方向改变和重新绘制时表现良好。还支持图例视图。
可定制的颜色,可以开启或关闭图例(要查看图例,请查看下面的截图)
可以调整环中每种颜色的百分比。您还可以更改您想要开始绘制颜色的点
您可以在中间附加图片或文本(或什么都不加)
可以修改边框宽度
背景可以是透明的或任何颜色。如果总百分比小于100%,则圆的剩余部分是透明的(如右所示)
您可以做得比这更多 ^^^
在您的项目 git 文件夹中输入
git submodule init
git submodule add --copy link to the repo--
git submodule update
从 CircleStatus/CircleStatus 文件夹中复制所有文件
这强烈不建议,因为您将无法看到代码更新。克隆或下载源代码,然后从 CircleStatus/CircleStatus 文件夹中复制所有文件。
通过克隆并查看演示来了解有关实现的更多示例。您可以通过 Storyboard 或使用代码添加视图
// in your view.h download the library
#import <CircleStatus/NOCSView.h>
// then add a property
@property (nonatomic, strong) NOCSView *csView;
// alloc & init the view or setup this via storyboard
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_csView = [[NOCSView alloc] initWithFrame:frame]; // + update the frame
[self addSubview:_csView];
}
return self;
}
// in your controller you can change outlook of the control
- (void)viewDidLoad {
[super viewDidLoad];
// fill with data
[_csExampleView.csView setPercentageColorArray:@[[[NOCSPercentageColor alloc] initWithColor:[UIColor greenColor] percentage:0.7f],
[[NOCSPercentageColor alloc] initWithColor:[UIColor yellowColor] percentage:0.3f]]];
// setup middle view: either text or image or nothing
[_csExampleView.csView.textLabel setText:@"Chart"];
// [_csExampleView.csView.imageView setImage:[UIImage imageNamed:@"test"]];
// setup chart view
[_csExampleView.csView setRadius:50.f];
[_csExampleView.csView setFillColor:[UIColor colorWithWhite:1.f alpha:0.4f]];
[_csExampleView.csView setStartAngle:15];
[_csExampleView.csView setLineWidth:10];
// setup legend
[_csExampleView.csView setShowsLegend:NO];
[_csExampleView.csView.legendView setLegendPosition:CSLegendPositionRight];
}
Natalia Osiecka,[email protected]
在 Apache 2.0 许可下可用。有关更多信息,请参阅 LICENSE 文件。
需要Xcode 5,针对iOS 5.1.1或更高版本