如何在我的iOS应用程序中使用“DEGREE”

时间:2012-12-28 11:51:35

标签: objective-c uibezierpath cashapelayer

嗨,我需要制作2D拱形。我在哪里遇到问题

arc.path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(50, 100)
                                                  radius:80.0
                                                  startAngle:DEGREE(65)
                                                  endAngle:DEGREE(90)
                                                  clockwise:NO].CGPath;

我收到错误

Undefined symbols for architecture i386: "_DEGREE", referenced from:

我知道我没有包含一些头文件,我可以知道要包含哪个头文件吗?

3 个答案:

答案 0 :(得分:10)

DEGREE是宏,不是方法!!!

你可以很容易地猜出它的名字。 命名约定发挥作用

您必须将其定义为:

#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)

#define DEGREE(angle) ((angle) / 180.0 * M_PI)

答案 1 :(得分:7)

它应该是自定义宏,您也可以声明自己并将其命名为您的名字。请尝试以下操作,将其放在标题或实现文件中的任何位置。

#define DEGREE(radians) ((radians) * (180.0 / M_PI))

答案 2 :(得分:0)

希望它适合你...

(CGFloat) radians:(CGFloat) degrees
{
    CGFloat angle = degrees * M_PI / 180.0;
    return angle;
}

@Matthias Bauch:感谢您的信息。