我在 x 和 y 方向上将 UIBezierPath(由一个 [0,0 - 1x1] rect 构建)缩放 2 倍。UIBezierPath ".bounds" 没问题(即按预期缩放),而 ".CGPath" 保持不变......
代码:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0,
1, 1)];
NSLog(@"path.bounds box before transform:%@",
NSStringFromCGRect(path.bounds));
NSLog(@"path.CGPath box before transform:%@",
NSStringFromCGRect(CGPathGetBoundingBox(path.CGPath)));
[path applyTransform:CGAffineTransformMakeScale(2, 2)];
NSLog(@"path.bounds box after transform:%@",
NSStringFromCGRect(path.bounds));
NSLog(@"path.CGPath box after transform:%@",
NSStringFromCGRect(CGPathGetBoundingBox(path.CGPath)));
return 0;
}
输出:
path.bounds box before transform:{{0, 0}, {1, 1}}
path.CGPath box before transform:{{0, 0}, {1, 1}}
path.bounds box after transform:{{0, 0}, {2, 2}}
path.CGPath box after transform:{{0, 0}, {1, 1}}
为什么?