简体   繁体   English

当动画块位于子视图之后时,UIView不会移动子视图

[英]UIView does not move a subview when a animation block is after it

I have this UIView class. 我有这个UIView类。 It has 4 Views in it: 它具有4个视图:

  1. self.view The view of the class itself. self.view类本身的视图。
  2. Above that twitterButtonView that holds: 在上面的twitterButtonView之上:
  3. A UIImageView of a button. 按钮的UIImageView
  4. Above that a hidden view of the back of the button. 上方是按钮背面的隐藏视图。

The self.view has a frame of (30, 380, 68, 66); self.view的框架为(30, 380, 68, 66); self.view (30, 380, 68, 66);

I want to be able to tab the button and then it scales up accompanied by a UIViewAnimationTransitionFlipFromRigh t. 我希望能够UIViewAnimationTransitionFlipFromRigh该按钮,然后将其放大并伴随UIViewAnimationTransitionFlipFromRigh t。 Before the animation starts I set the frame of the class to be the whole screen. 在动画开始之前,我将类的框架设置为整个屏幕。 (I have to do this for the class to still respond to touches) Thats where my button moves to the top left. (我必须这样做,以便班级仍然要响应触摸),这就是我的按钮移至左上方的位置。 I'm doing a twitterButtonView.center = somePoint and nothing happens to the button view: (I removed unimportant parts) 我正在做一个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];

The button moves to the center. 按钮移到中间。 But the animation starting point is 34,33. 但是动画的起点是34,33。 Why is that? 这是为什么?

because the self.view center is 34, 33. 因为self.view中心是34、33。

Instead try changing the origin of the frame (x or y). 而是尝试更改帧的原点(x或y)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM