1

我有一个 UIView 的子类,它正在绘制一个位置图标。当我将视图旋转几度时,它的边界(使用绿色突出显示CGContextAddRect)似乎发生了巨大变化,导致我的绘图看起来失真。


(来源:bytolution.com


(来源:bytolution.com

这是我的代码:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.locationTagView.frame = CGRectMake(40, 80, 240, 240);
    CGAffineTransform transform = CGAffineTransformMakeRotation(DegreesToRadians(30));
    self.locationTagView.transform = transform;
    [self.view addSubview:self.locationTagView];
}
4

1 回答 1

2

这修复了它:

#define LOCTAG_HEIGHT 240
#define LOCTAG_WIDTH 240

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.locationTagView.frame = CGRectMake(40, 80, LOCTAG_WIDTH, LOCTAG_HEIGHT);
    self.locationTagView.bounds = CGRectMake(0, 0, LOCTAG_WIDTH, LOCTAG_HEIGHT);
    CGAffineTransform transform = CGAffineTransformMakeRotation(DegreesToRadians(340));
    self.locationTagView.transform = transform;
    [self.view addSubview:self.locationTagView];
}


(来源:bytolution.com

单独设置边界使其工作!

于 2013-04-09T19:03:44.837 回答