TTWKPieChart 0.2.0

TTWKPieChart 0.2.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年3月

Aleh DzenisiukGuido van Loon 维护。




  • TouchTribe B.V.

一个组件,它简化了创建类似 Activity 应用程序中使用的动画 Apple Watch 风格饼图。

快速入门

用于与您的 WatchKit 扩展一起使用

  • 添加一个 WKInterfaceImage 到您的 storyboard 中,正好在您想显示图表的位置;

  • 确保其模式设置为 'Center',并将宽度和高度设置为 'Size To Fit Content';

  • 将图像或组连接到您的 WKInterfaceController 子类中的相应属性;

  • 导入 TTWKPieChart.h;

  • 在 awakeWithContext: 方法中创建和配置饼图,例如

    // Create and configure the chart generator
    TTWKPieChart *pieChart = [[TTWKPieChart alloc] init];
    pieChart.radius = floorf([WKInterfaceDevice currentDevice].screenBounds.size.width * 0.45);
    pieChart.bandWidth = 14;
    // ...
    
    TTWKPieChartBand *band1 = [[TTWKPieChartBand alloc] init];
    band1.icon = [UIImage imageNamed:@"test-icon-1"];
    band1.caption = @"LOREM";
    band1.startColor = [UIColor colorWithRed:1.0000 green:0.0941 blue:0.0392 alpha:1.0];
    band1.endColor = [UIColor colorWithRed:1.0000 green:0.0275 blue:0.6392 alpha:1.0];
    band1.backgroundColor = [UIColor colorWithRed:0.1608 green:0.0314 blue:0.0667 alpha:1.0];
    band1.value = 0.86;
    // ...
    
    // Configure the text to display
    pieChart.largeText = [[NSAttributedString alloc]  initWithString:@"125"
    //...
    
    // Generate the animated image at 15 FPS, send it off to the device and begin animation
    _image = [pieChart animatedImageWithFrameRate:15];
    [self.chartImage setImage:_image];
    [self.chartImage startAnimatingWithImagesInRange:NSMakeRange(0, _image.images.count) duration:_image.duration repeatCount:1];
    

请参阅示例项目以获取完整的示例。

安装

或者,您可以直接将 Pod/Classes 中的类拖放到您的项目中。

作者 & 许可证

TTWKPieChart 由 TouchTribe B.V. 创建,并可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。