2012-10-06 54 views
0

爲了使圖像看起來由左到右,我設置了anchorPoint像這樣:設置一個UIImageView anchorPoint沒有在接口改變位置生成器

myImageView.layer.anchorPoint = CGPointMake(0.0f, 1.0f); 

然後設置其動畫:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationCurve:UIViewAnimationCurveLinear]; 

myImageView.transform = CGAffineTransformMakeScale(1.0, 1.0); 

[UIView commitAnimations]; 

動畫效果很好,但通過更改圖像的anchorPoint,圖像不會出現在Interface Builder中設置的位置,當設置了anchorPoint時,它會移動相當多的位置。

有沒有人知道是否有方法來設置anchorPoint或完成此效果而不更改在Interface Builder中圖像的位置?

謝謝!

+0

確保你明白什麼是anchorPoint:http://stackoverflow.com/a/22188420/550393 – 2cupsOfTech

回答

0

在viewDidLoad中:剛初始化你ImageView的框架:

[ImageView的SETFRAME:CGRectMake(900,0,69,39)];

,並寫下面的代碼:

[UIView animateWithDuration:0.5 
          delay:0.1 
         options:UIViewAnimationOptionTransitionCurlDown 
        animations:^{ 
         //animation code 
         ImageView.frame = CGRectMake(0, 0, 320, 345); 

        } completion:^(BOOL finished) { 
         //completion code 

        }]; 
+0

請根據你的動畫從那裏已設置你的框架(意思是你需要從左邊開始......所以在animateWithDuration :)中根據它設置框架) –

+0

我已經暫時設置了框架。忽略框架。 –