从特定点缩放
我正在使用此代码从特定点进行缩放
CGPoint getCenterPointForRect(CGRect inRect)
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
return CGPointMake((screenRect.size.height-inRect.origin.x)/2,(screenRect.size.width-inRect.origin.y)/2);
}
-(void) startAnimation
{
CGPoint centerPoint = getCenterPointForRect(self.view.frame);
self.view.transform = CGAffineTransformMakeTranslation(centerPoint.x, centerPoint.y);
self.view.transform = CGAffineTransformScale( self.view.transform , 0.001, 0.001);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kTransitionDuration];
self.view.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
它不起作用。从特定点进行缩放的正确方法是什么。
没有找到相关结果
已邀请:
1 个回复
黎喊病
你的视图最终占据了整个屏幕,然后它将保持在屏幕中间的中心位置,有点像一个很远的地方,你正朝着它前进。 假设您希望它从(x,y)增长并移动到屏幕中心,那么您需要更多类似的东西:
其中locationToZoomFrom将成为视图的初始中心,其正常中心将按其框架作为目标。