之前,你需要改變view.layer的anchorPoints
-(void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view
{
CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x, view.bounds.size.height * anchorPoint.y);
CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x, view.bounds.size.height * view.layer.anchorPoint.y);
newPoint = CGPointApplyAffineTransform(newPoint, view.transform);
oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);
CGPoint position = view.layer.position;
position.x -= oldPoint.x;
position.x += newPoint.x;
position.y -= oldPoint.y;
position.y += newPoint.y;
view.layer.position = position;
view.layer.anchorPoint = anchorPoint;
}
,你應該實現這樣的。
[self setAnchorPoint:CGPointMake(1,1)];
UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
self.toNextButton.transform = CGAffineTransformMakeRotation(180.0f);
[UIView commitAnimations];
你可以嘗試設置'toNextButton'的中心點在廈門國際銀行給它的右下角可能,這將解決您的問題:) –
檢查這個帖子:http://stackoverflow.com/questions/6160519 /如何旋轉一個任意點的對象 –