我使用CGPath
绘制了多边形(六边形),绘制后添加到CAShapeLayer
。现在当我点击多边形时,那时我想要改变那个没有动画的多边形的比例(更大)。
这是代码:
//pointsForPolygonInRect will generate points for polygon
NSArray *arrayOfCoordinates = [self pointsForPolygonInRect:CGRectMake(0, 0, 400, 400)
numberOfSides:6];
NSEnumerator *enumerator = [arrayOfCoordinates objectEnumerator];
CGMutablePathRef path = CGPathCreateMutable();
CGPoint firstCoordinatePoint = [[enumerator nextObject] CGPointValue];
CGPathMoveToPoint(path, NULL, firstCoordinatePoint.x, firstCoordinatePoint.y);
CGPoint nextCoordinatePoint;
NSValue *coordinate;
while (coordinate = [enumerator nextObject]) {
nextCoordinatePoint = [coordinate CGPointValue];
CGPathAddLineToPoint(path, NULL, nextCoordinatePoint.x, nextCoordinatePoint.y);
}
CAShapeLayer* layer = [CAShapeLayer layer];
layer.frame = CGPathGetPathBoundingBox(path);
layer.path = path;
CGPathRelease(path);
layer.fillColor = [UIColor redColor].CGColor;
[self.layer addSublayer:layer];
请帮助我。谢谢你。