0

我正在尝试为图像(UIImageView)添加边框,除了一件事外一切正常:当我调整图像大小时,我的形状变得更大(或更小)。这是一些代码:

 CGPoint center = view.center; // view is a UIImageView
 CGAffineTransform transform = CGAffineTransformIdentity;
 CGFloat angle = [(NSNumber *)[view valueForKeyPath:@"layer.transform.rotation.z"] floatValue];
 CGFloat scale = [(NSNumber *)[view valueForKeyPath:@"layer.transform.scale"] floatValue];
 transform = CGAffineTransformTranslate(transform, center.x, center.y);
 transform = CGAffineTransformScale(transform, scale, scale);
 transform = CGAffineTransformRotate(transform, angle);
 transform = CGAffineTransformTranslate(transform, -center.x, -center.y);
 CGPathRef path = CGPathCreateWithRect(view.frame, &transform); // looks like the problem is here
 shape.path = path; // shape is a CAShapeLayer
 CGPathRelease(path);
4

1 回答 1

0

通过更换解决

CGPathRef path = CGPathCreateWithRect(view.frame, &transform); 

CGPathAddLines(path, nil, points, 5);
于 2013-08-13T15:04:43.260 回答