当用户点击其 super View 时,我正在运行此代码以缩小 UIView。然而,当应用 CGAffineTransformScale() 时,它也会改变中心。这是预期的行为吗?
-(void) onTap:(UITapGestureRecognizer *)tap{
[UIView animateWithDuration:1.2
delay:0
options:0
animations:^{
CGAffineTransform transform = self.icon.transform;
NSLog(@"Previous center: %@", NSStringFromCGPoint(self.icon.center));
self.icon.transform = CGAffineTransformScale(transform, 0.5, 0.5);
NSLog(@"Next center: %@", NSStringFromCGPoint(self.icon.center));
} completion:^(BOOL finished) {
//
}];
}
最佳答案
我终于发现了发生了什么:自动布局正在重新定位 subview 并更改中心。
关于cocoa-touch - 将 Scale AffineTransform 应用于 UIView 会改变其中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12513092/