2013-01-10 47 views
0

干扰我有用于将图像跳到不同位置的UIView animateWithDuration与其他CGRectMake

image.frane=CGRectMake(x,y,w,h); 

一个CGRectMake然后我想平移和缩放Label(在相同ViewController)到另一位置

CGPoint newCenter = CGPointMake(x,y); 
[UIView animateWithDuration: 1.0 
    delay: 0 
    options: 0 
    animations:^{label.center = newCenter ; label.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.2, 0.2);} 
        completion:^(BOOL finished) { 
         label.transform = CGAffineTransformMakeScale(1.0, 1.0); 
         label.alpha = 0; 
    } 
]; 

我遇到的问题是当我使用animateWithDuration图像不移动,但Label这样做。如果我将动画注释掉,图像会再次移动。难道我做错了什么?

+0

将请您详细阐述您的问题和代码? –

+0

是'image.frane'这是一个错字吗? –

+0

也是这是一个iOS6的应用程序,你使用自动布局? –

回答

0

试试这个娄代码...

[UIView animateWithDuration:1.0f animations:^{ 
    imageView.frame = CGRectMake(newCenter.x, newCenter.y, imageView.frame.size.width, imageView.frame.size.height); 
}]; 

您也可以移动UIImageView或其他任何与此娄代码...我用滚动此代码UIScrollView当键盘出现..我添加代码与您的要求..

UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0f]; 
imageView.frame = CGRectMake(newCenter.x, newCenter.y, imageView.frame.size.width, imageView.frame.size.height); 
[UIView commitAnimations]; 

我希望这对您有所帮助......

+1

谢谢,让他们工作。虽然如果我添加行到setAnimation _label.transform = CGAffineTransformMakeScale(0.2,0.2); 它再次第一次停止工作 – harbourmaster

+0

是的伙计这就是为什么它不工作:) –

+0

什么是增加一个规模到CGRectMake的最佳方式?我以前没有真正使用过这些,但似乎调整框架的宽度和高度不会随着时间的推移而立即适用。 – harbourmaster

相关问题