【问题标题】:set a UIImageView anchorPoint without changing the location in Interface Builder在不更改界面生成器中的位置的情况下设置 UIImageView 锚点
【发布时间】:2012-10-06 03:52:23
【问题描述】:

为了使图像从左到右显示,我将锚点设置为:

myImageView.layer.anchorPoint = CGPointMake(0.0f, 1.0f);

然后对其进行动画处理:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];

myImageView.transform = CGAffineTransformMakeScale(1.0, 1.0);

[UIView commitAnimations];

动画效果很好,但是通过更改图像的锚点,图像不会出现在界面生成器中设置的位置,当设置锚点时,它会移动很多。

有人知道是否有一种方法可以设置anchorPoint 或在不更改图像在Interface Builder 中的位置的情况下实现此效果吗?

谢谢!

【问题讨论】:

标签: iphone interface-builder layer


【解决方案1】:

在 ViewDidLoad 中:只需初始化您的 ImageView 框架:

[ImageView setFrame:CGRectMake(900, 0, 69, 39)];

并在下面写下这段代码:

    [UIView animateWithDuration:0.5 
                          delay:0.1 
                        options:UIViewAnimationOptionTransitionCurlDown
                     animations:^{
                         //animation code
                         ImageView.frame = CGRectMake(0, 0, 320, 345);

                     } completion:^(BOOL finished) {
                         //completion code

                     }];

【讨论】:

  • 请根据你的动画从哪里来设置你的框架。(意​​味着你需要从左边开始..所以在 animateWithDuration 中根据它设置框架:)
  • 我临时设置了框架。忽略框架。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 2013-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多