我编写了一些代码来使用 UIBezierPath 创建以下内容,但它没有用。有人可以帮助我我的代码有什么问题。
但我尝试使用drawRect:它工作正常......我的问题与我在UIBezierPath中需要的一样,
+ (UIBezierPath *)DropShape:(CGRect)Frame {}
我使用drawRect的代码:是
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);
在此先感谢...
最佳答案
有一个应用程序叫 PaintCode您可以免费试用。
您可以在 Canvas 上绘图,它会生成 drawRect
您可以复制并粘贴到您的应用程序中的代码。
我认为您不能从试用版复制,但它会创建您可以手动输入代码的路径。
值得一看。
关于ios - 如何使用 UIBezierPath 创建水滴形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26334784/