iphone - 从 UIImageView 的中心动画 UIImageView

标签 iphone ios objective-c uiimageview uiviewanimation

我有一个 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 的中心开始动画,而是从左上角开始。

有人知道吗?

最佳答案

我在 Borrden 的帮助下解决了这个问题。这就是我的解决方案。

首先创建一个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");
                     }];

关于iphone - 从 UIImageView 的中心动画 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17362016/

相关文章:

iphone - Three20简单导航

ios - 触摸单元格时 UICollectionView 崩溃

IOS- UITableView 滚动回到顶部

ios - 使用外观更改背景颜色 TableView 箭头?

iphone - 当手绕传感器移动时,接近传感器打开

iphone - 在 NSUserDefaults 中存储值是否有任何限制?

ios - 请求facebook图片时错误码2500

iphone - Game Center 以编程方式邀请好友

objective-c - CocoaHTTPServer2.3 函数 'LOG_OBJC_MAYBE'的隐式声明在C99中无效