Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用UIBezierPath创建水滴形状_Ios_Objective C_Ios7_Shape_Uibezierpath - Fatal编程技术网

Ios 如何使用UIBezierPath创建水滴形状

Ios 如何使用UIBezierPath创建水滴形状,ios,objective-c,ios7,shape,uibezierpath,Ios,Objective C,Ios7,Shape,Uibezierpath,我用UIBezierPath编写了一些代码来创建下面的代码,但它不起作用。有人能帮我一下我的代码有什么问题吗 但我试过drawRect:它很好用……我的问题和我在UIBezierPath中需要的一样 + (UIBezierPath *)DropShape:(CGRect)Frame {} 我的代码使用drawRect:is CGContextRef context = UIGraphicsGetCurrentContext(); CGGradientRef gradient; CGColorS

我用UIBezierPath编写了一些代码来创建下面的代码,但它不起作用。有人能帮我一下我的代码有什么问题吗

但我试过drawRect:它很好用……我的问题和我在UIBezierPath中需要的一样

+ (UIBezierPath *)DropShape:(CGRect)Frame {}
我的代码使用drawRect:is

CGContextRef context = UIGraphicsGetCurrentContext();
CGGradientRef gradient;
CGColorSpaceRef colorspace;
CGFloat locations[3] = { 0.0, 0.5, 1.0 };

NSArray *colors = @[(id)[UIColor redColor].CGColor];

colorspace = CGColorSpaceCreateDeviceRGB();

gradient = CGGradientCreateWithColors(colorspace,
                                      (CFArrayRef)colors, locations);

CGPoint startPoint, endPoint;
CGFloat startRadius, endRadius;

startPoint.x = self.frame.size.width/2;
startPoint.y = 30;
endPoint.x = 175;
endPoint.y = 175;
startRadius = 0;
endRadius = 75;

CGContextDrawRadialGradient(context, gradient, startPoint,
                            startRadius, endPoint, endRadius, 0);
提前感谢…

有一个名为的应用程序,你可以免费试用

您可以在画布上绘制,它将生成
drawRect
代码,您可以复制并粘贴到应用程序中

我不认为您可以从试用版复制,但它将创建一个路径,您可以手动在代码中键入该路径


值得一看。

请注意,这与
xcode
IDE无关,因此我删除了该标记。