IOS:动画与的UIImageView [英] IOS: animation with UIImageView

查看:161
本文介绍了IOS:动画与的UIImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个imageViews,我称之为的firstView和secondView;我不得不这样做移动第三ImageView的,我称之为imageView3动画。这imageView3里面的firstView,我这样做code

I have two imageViews that I call firstView and secondView; I have to do an animation that move a third imageView that I call imageView3. This imageView3 is inside firstView and I do this code

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[imageView3 setFrame:frameinSecondView];
[UIView commitAnimations];
//[imageView3 removeFromSuperview];
//[secondView addSubview:imageView3];

本code我可以移动到imageView3但secondView的问题是,我不能够设置imageView3在正确的框架frameinSeconView而是如果我使用评论code

with this code I can move imageView3 to secondView but the problem is that I'm not able to set imageView3 in the correct frame "frameinSeconView"; instead if I use the commented code

[imageToMove removeFromSuperview];
[scrollViewAlfabeto addSubview:imageToMove];

imageView3去正确的框架,但我看不到动画,因为当它开始其动画,imageview3从广告的firstView消失出现,当它去secondView

imageView3 go on the correct frame but I don't see the animation because when it starts its animation, imageview3 disappear from firstView ad appear when it go on secondView

我该如何解决有一个正确的动画,这两个imageViews之间有正确的帧。

How Can I solve to have a correct animation, with a correct frame between these two imageViews.

推荐答案

您正试图从1传imageView3至2吧?
从imageView1删除它,并把它放在窗口视图,执行从1动画2的的结束动画从窗口视图取出,插入imageView2

You are trying to pass imageView3 from 1 to 2 right? Remove it from imageView1 and place it on the windowView, do the animation from 1 to 2 and wait to end the animations to remove from windowView and insert into imageView2

如何的的? ...好有一个[句子东西]结构做到这一点,但我不知道怎么回事,不是说(香港专业教育学院的原因没有找到如何)我开始使用动画块:D

how to wait? ... well there is a [sentence something] structure that do that, but i dont know how is it, instead of that (cause ive never found how) i started to use "animation blocks" :D

什么是动画块?
块:对象,这意味着一个动作;
下面是使用块对象的动画的例子块1,块2(code PARTC)

what is an animation block? block: object that means an action; below is an example of an animation using block objects block1, block2 (CODE PARTC)

    [UIView animateWithDuration:2 delay:0 
                    options:UIViewAnimationCurveEaseIn 
                 animations: block1
                 completion: block2
    ];

这意味着它会做块1定义的动作,就好像它们是内开始提交动画句子,(美丽的部分),项目建成后,他们将在块2执行的操作! !:D

It means that it will do actions defined in block1, as if they were inside begin-commit animation sentences, and (the beautiful part) after its COMPLETION they will do the actions in block2! :D!

但什么是A F ---- NG块?;好...
THIS IS A F ---- NG BLOCK:

but what is a f----ng block?; well... THIS IS A F----NG BLOCK!:

返回void(code A部)块:

    void (^block1)(void) = ^{
    centerPortrait.frame = frame1;
    if (lookingMenu==NO)
        listTableView.frame = frameT1;
    };

返回BOOL块(完成后:你需要一个布尔值),并有在另一个动画(code B部分)

    void (^block2)(BOOL) = ^(BOOL got){
    [UIView animateWithDuration:halfDuration delay:0 
                        options:UIViewAnimationCurveEaseIn 
                     animations:^{
                         centerPortrait.image = image;
                         centerPortrait.frame = frame2;
                         if (lookingMenu==YES)
                             listTableView.frame = frameT2;
                     } 
                     completion:nil
     ];
    };

我用这个来使图像hohohoho的假旋转
不管怎么说如果u剪掉了它,顺序是A部,B,C:P

I've used this to make a fake rotation of an image hohohoho Anyways if u didnt got it, the order is PARTA,B,C :P

阅读:
<一href=\"http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html%23//apple_ref/doc/uid/TP40007502-CH7-SW1\" rel=\"nofollow\">http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html%23//apple_ref/doc/uid/TP40007502-CH7-SW1

在这里我得到了如何使用块:D,和伟大的RAYWENDERLICH的下面有一个有用的教程:
http://www.raywenderlich.com/2454/how-to -use-的UIView动画教程

is where i got how to use blocks :D, and heres an useful tutorial of the great RAYWENDERLICH: http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial

希望它帮助!

这篇关于IOS:动画与的UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆