我正在尝试找出一种添加或附加路径(我已经创建)的方法,并且能够以某种方式设置绘制路径的位置。
这是我正在谈论的一个例子:
//everything here can be compiled in a regular UIViewController
//this example is very trivial but it illustrates basically what I want to do
CGRect preMadeRect = CGRectMake(0.0f, 0.f, 50.f, 50.f);
CGPathRef preMadePath = CGPathCreateWithEllipseInRect(preMadeRect, NULL);
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
//I thought that maybe if I moved to a new point
//the path would respect the starting point as its new
//x and y coordinates
CGContextMoveToPoint(context, 50.f, 50.f);
//I am adding a path
//I want the path to be positioned at new coordinates
//within the context
CGContextAddPath(context, preMadePath);
CGContextStrokePath(context);
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imageView = [[UIImageView alloc]initWithImage:resultImage];
[self.view addSubview: imageView];
任何想法,将不胜感激。