Animation 在iPhone中扩展和缩小UIView

Animation 在iPhone中扩展和缩小UIView,animation,uiview,Animation,Uiview,我正在开发一个类似iPhone游戏的应用程序,在这个应用程序中,我必须在UIButoons上提出一个问题和相应的答案。当用户按下任何按钮时,我会根据选择的答案显示正确和错误的图像。我通过以下代码创建应答视图,并将其附加到主视图: -(void)ShowOutputImageAsAnswerView:(BOOL)correct { viewTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector

我正在开发一个类似iPhone游戏的应用程序,在这个应用程序中,我必须在UIButoons上提出一个问题和相应的答案。当用户按下任何按钮时,我会根据选择的答案显示正确和错误的图像。我通过以下代码创建应答视图,并将其附加到主视图:

-(void)ShowOutputImageAsAnswerView:(BOOL)correct
{   

    viewTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(RemoveSubViewFromMainView) userInfo:nil repeats:YES];
    UIView  *viewOutput = [[UIView alloc]initWithFrame:CGRectMake(200, 100, 80, 80)];
    viewOutput.tag  = 400;
    viewOutput.backgroundColor = [UIColor clearColor];
    UIImageView *imgAns = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
    if (correct)
    {
        imgAns.image = [UIImage imageNamed:@"correct_icon.png"];
    }
    else
    {
        imgAns.image = [UIImage imageNamed:@"wrong_icon.png"];
    }   
    [viewOutput addSubview:imgAns];
    [self.view addSubview:viewOutput];
    [self.view bringSubviewToFront:viewOutput];

    [imgAns release];
    [viewOutput release];   

}
我必须以动画形式显示这个答案视图。这个动画将从0像素到80像素开始。意味着扩展和缩小视图

如何实施?
它可以直接与imgAns一起使用吗?

您可以通过以下操作创建动画:

myView.frame=CGRectMake(myView.frame.origin.x,myView.frame.origin.y,0.,0.);

[UIView animateWithDuration:1
                     animations:^{
                        //put your animation here
                        myView.frame=CGRectMake(myView.frame.origin.x,myView.frame.origin.y,80.,80-);    
                     }];

我还没有尝试过这段代码,但它应该能让您很好地了解如何操作。

您可以通过执行以下操作来创建动画:

myView.frame=CGRectMake(myView.frame.origin.x,myView.frame.origin.y,0.,0.);

[UIView animateWithDuration:1
                     animations:^{
                        //put your animation here
                        myView.frame=CGRectMake(myView.frame.origin.x,myView.frame.origin.y,80.,80-);    
                     }];
我还没有尝试过这段代码,但它应该能让您很好地了解如何去做