从UIImageView的中心对UIImageView进行动画处理 [英] Animate a UIImageView from center of the UIImageView

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

问题描述

我有一个UIImageView,应该从size (0,0) --> (93,75)

我有以下内容

  [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionTransitionNone
                 animations:^{
                     imgButton.layer.anchorPoint = CGPointMake(imgButton.bounds.size.width/2, imgButton.bounds.size.height/2);
                     CGRect btnFrame = imgButton.frame;
                     btnFrame.size.width = 105;
                     btnFrame.size.height = 85;
                     imgButton.frame = btnFrame;
                 }
                 completion:^(BOOL finished) {
                     [self animageButton2:imgButton];
                 }];

这是可行的,但是我唯一的问题是它不是从UIImageView的中心进行动画设置,而是从左上角进行动画设置.

This is working but the only problem I have is that it is not animating from the center of the UIImageView but from the top left corner.

有人知道吗?

推荐答案

我已经在Borrden的帮助下解决了它.这就是我的解决方案.

I've solved it with the help of Borrden. This is what my solution was.

首先创建一个imageview

First create an imageview

UIImageView *imgLineup = [[UIImageView alloc]initWithFrame:CGRectMake(10, y, 93, 75)];
imgLineup.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0, 0.0);

然后执行以下操作.

[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         imgButton.layer.anchorPoint = CGPointMake(0.5, 0.5);
                         imgButton.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);

                     }
                     completion:^(BOOL finished) {
                        NSLog(@"done");
                     }];

这篇关于从UIImageView的中心对UIImageView进行动画处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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