【问题标题】:UIView does not move a subview when a animation block is after it当动画块在它之后时,UIView 不会移动子视图
【发布时间】:2010-05-25 06:45:26
【问题描述】:

我有这个UIView 课程。 它有 4 个视图:

  1. self.view班级观 本身。
  2. 在 twitterButtonView 上方:
  3. 一个按钮的UIImageView
  4. 上方是按钮背面的隐藏视图。

self.view 的框架为(30, 380, 68, 66);

我希望能够点击按钮,然后它会随着UIViewAnimationTransitionFlipFromRight 放大。在动画开始之前,我将类的框架设置为整个屏幕。 (我必须这样做才能让班级仍然响应触摸)这就是我的按钮移动到左上角的地方。我正在做一个twitterButtonView.center = somePoint 并且按钮视图没有任何反应:(我删除了不重要的部分)

        // I save the center of the class. Its where the the class is in the window.
    oldCenter = self.center;
    self.frame = CGRectMake(0, 0, 320, 480);
    // Set the button to the position where the class was.This is x=63 y=413 in the debugger
    // If I return; after this everything is fine and the class has the frame set to the whole
    // screen and the button is at 62,413
    twitterButtonView.center = oldCenter;
    [UIView beginAnimations:@"twitterButtonFlip" context:nil];
    [UIView setAnimationDuration:1.0];
    twitterButtonView.center = CGPointMake(160,220);
    [UIView commitAnimations];

按钮移动到中心。但是动画起点是34,33。这是为什么呢?

【问题讨论】:

    标签: iphone objective-c animation uiview


    【解决方案1】:

    因为self.view中心是34、33。

    尝试更改框架的原点(x 或 y)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多