2013-06-26 43 views
0

什么是最简单和性能最低的方法来实现这一目标?如何在iOS中的图像上绘制UIBezierPath?

现在我有一个超过60000行的UIBezier路径。我想从中创建一个图像,稍后将在屏幕上移动并拉伸。

+0

看到这个问题第一个答案:http://stackoverflow.com/questions/11739816/ios-uiimage-image-upside-down但不是在上下文中绘制一个UIImage,在上下文 – V1ru8

+0

绘制你的路径,但如何我是否可以绘制该图像? CGContextDrawPath?或者我应该只使用[path stroke]并将其绘制到图像上? – HSNN

+0

http://stackoverflow.com/questions/17408209/how-to-create-a-image-with-uibezierpath/40908425#40908425 – Shrawan

回答

9

只需创建一个图形上下文,并绘制路径进去,就像这样:

UIGraphicsBeginImageContextWithOptions(path.bounds.size, NO, 0.0); //size of the image, opaque, and scale (set to screen default with 0) 
[path fill]; //or [path stroke] 
UIImage *myImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

如果你在走动的形象策划,你就需要把它拉进你的看法,或最好一个UIImageView,它是该视图的子视图。这比每次用户移动手指时重新绘制视图都快。

希望这会有所帮助!

+0

第一线对的Xcode警告:'的功能隐式声明“UIGraphicsCreateImageContextWithOptions”是无效的'和建筑失败:'对于架构i386的未定义符号: “_UIGraphicsCreateImageContextWithOptions”' – HSNN

相关问题