小编deb*_*k63的帖子

对UIBezierPath + applyTransform + CGPath感到困惑

我在x和y方向上按比例2缩放UIBezierPath(由一个[0,0 - 1x1] rect构建).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;        
}
Run Code Online (Sandbox Code Playgroud)

输出:

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}}
Run Code Online (Sandbox Code Playgroud)

为什么?

core-graphics cgpath ios uibezierpath

3
推荐指数
1
解决办法
5134
查看次数

标签 统计

cgpath ×1

core-graphics ×1

ios ×1

uibezierpath ×1