2013-04-09 25 views
2

我有一个绘制位置图标的UIView的子类。当我将视图旋转几度时,界限(使用CGContextAddRect以绿色突出显示)似乎会发生剧烈变化,导致我的绘图看起来失真。旋转的UIView和核心图形的边界

http://bytolution.com/Screenshot%202013.04.09%2016.41.00.png http://bytolution.com/Screenshot%202013.04.09%2016.41.43.png

这里是我的代码:

- (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]; 
} 
+0

我试过'self.locationTagView.autoresizingMask = UIViewAutoresizingNone;'但它不起作用。看到我的答案在下面! – Dario 2013-04-09 19:05:39

回答

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]; 
} 

http://bytolution.com/Screenshot%202013.04.09%2021.02.39.png

设置界限分开使得它的工作!