ios - 如何使用 UIBezierPath 创建水滴形状

标签 ios objective-c ios7 shape uibezierpath

我编写了一些代码来使用 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);

在此先感谢... Screen

最佳答案

有一个应用程序叫 PaintCode您可以免费试用。

您可以在 Canvas 上绘图,它会生成 drawRect您可以复制并粘贴到您的应用程序中的代码。

我认为您不能从试用版复制,但它会创建您可以手动输入代码的路径。

值得一看。

关于ios - 如何使用 UIBezierPath 创建水滴形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26334784/

相关文章:

ios - 将应用程序上传到应用程序商店,支持 iPad,稍后支持 iPhone

objective-c - iPhone应用程序在替换视频文件时崩溃

ios - 在 CitrusPay 网关 swift ios 中设置卡类型的问题

ios - CSS font-family HelveticaNeue-Light 不呈现粗体

ios - iOS7 是如何理解 Swift Code 的?操作系统是否支持 Swift?

ios - 如何在iOS中实现Android的getViewById?

ios - 如何在 IOS 7 的模拟器中访问保存的照片

objective-c - 在核心图形中颠倒文本

objective-c - Restkit - 子映射不继承其父映射?

ios - iOS7 相机拍照模式全屏