我一直在研究CGAffineTransforms,并想知道是否有办法拍摄视图并放大x,y坐标。我将缩放部分缩小了函数:
CGAffineTransformMakeScale(4.00 ,4.00);
但是我不确定如何将缩放与可能的x,y坐标联系起来。有没有人做过这样的事情?我可能在使用这些功能时不正确吗?
-(void)buttonSelected:(id)sender
{
UIButton *b = sender;
CGPoint location = b.frame.origin;
[UIView animateWithDuration:1.3f delay:0.0f options:UIViewAnimationCurveEaseIn animations:^{
CGAffineTransform totalTransform =
CGAffineTransformMakeTranslation(-location.x , -location.y );
totalTransform = CGAffineTransformScale(totalTransform, 4.0f, 4.0f);
totalTransform = CGAffineTransformTranslate(totalTransform, location.x , location.y );
[self.view setTransform:totalTransform];
}completion:^(BOOL finished) {
}];
}
答案 0 :(得分:5)
您可以构建一个执行以下三个步骤的转换:
所以,例如。
// to use a point that is (109, 63) from the centre as the point to scale around
CGAffineTransform totalTransform =
CGAffineTransformMakeTranslation(-109.0f, -63.0f);
totalTransform = CGAffineTransformScale(totalTransform, 4.0f, 4.0f);
totalTransform = CGAffineTransformTranslate(totalTransform, 109.0f, 63.0f);
或者,可以说更简单地调整view.layer
的{{3}}。第二个想法的问题是,当你第一次调整锚点时,你会得到一个立即变换,因为所有其他定位都是以中心为基础。