2
我用Core Graphics繪製了多邊形。但我無法調整多邊形的大小。我用UIBezierPath繪製多邊形。這是我的代碼如何在iPhone中繪製可調整大小的多邊形?
CGPoint gestureStartPoint,currentPosition;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
currentPath = [[UIBezierPath alloc]init];
currentPath.lineWidth=1;
xx1 = 30;
yy1 = 30;
xx = 30;
yy = 30;
CGPoint gestureStartPoint,currentPosition;
}
return self;
}
- (void)drawRect:(CGRect)rect {
if(drawColor==nil){
[[UIColor redColor]setStroke];
[currentPath stroke];
}
else {
[drawColor setStroke];
[currentPath stroke];
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self];
currentPosition.x = xx;
currentPosition.y = yy;
xx = gestureStartPoint.x;
yy = gestureStartPoint.y;
[currentPath moveToPoint:(currentPosition)];
[currentPath addLineToPoint:(gestureStartPoint)];
[self setNeedsDisplay];
}
這是樣本resizable Polygon的鏈接。如何用這種可調整大小的屬性繪製多邊形?我不知道從哪裏開始製作可調整大小的多邊形。
我可以有你的電子郵件..必須問一些問題。? – mAc
嘿! Thanx ...你會添加到Gmail中 – mAc