相关疑难解决方法(0)

如何将度数转换为弧度?

我试图将此Obj-C代码转换为Swift代码,但我不知道这段代码的等价物应该是什么?

#define DEGREES_TO_RADIANS(degrees)((M_PI * degrees)/180)
Run Code Online (Sandbox Code Playgroud)

我用Google搜索并找到了这个

但我不明白在我的情况下如何在Swift中转换它?

macos macros objective-c ios swift

100
推荐指数
6
解决办法
7万
查看次数

使用Core Graphics制作饼图

到目前为止,我已经填补了一个圆圈,就是这样.我正在尝试制作一个饼图,代表满意和不满意客户的数量并展示它.我对CG非常陌生,并且想知道有人可以提出足够的代码给我一个想法或指导我.

我应该在底部圆圈表示满意客户的数量,然后在其上添加另一个圆圈以显示不满意的客户吗?我是以正确的方式接近它吗?

到目前为止,这是我的代码.

override func drawRect(rect: CGRect) {

    // Get current context
    let context = UIGraphicsGetCurrentContext()

    // Set color
    CGContextSetStrokeColorWithColor(context,UIColor(red: 0.2, green: 0.4, blue: 1, alpha: 1.0).CGColor)

    let rectangle = CGRectMake((frame.size.width / 3) - 50, frame.size.height / 2 + 40,220,220)
    CGContextAddEllipseInRect(context,rectangle)

    CGContextSetFillColorWithColor(context, UIColor(red: 0.2, green: 0.4, blue: 1, alpha: 1.0).CGColor)
    CGContextFillPath(context)
    CGContextStrokePath(context)

}
Run Code Online (Sandbox Code Playgroud)

编辑

此外,现在我开始看到我可能需要用一个基于不满意客户总数的弧来覆盖我的圈子.如何根据人数增加或减少覆盖弧的大小?

任何帮助将非常感谢!

core-graphics ios swift

24
推荐指数
1
解决办法
8606
查看次数

标签 统计

ios ×2

swift ×2

core-graphics ×1

macos ×1

macros ×1

objective-c ×1