0

I have a view interface which contains a subview touchWheel. On clicking a minimise button on interface I'd like to perform a transform & send the view to the bottom-right corner of my screen. The thing is that I want to "detach" the touchWheel view & send it to the corner separately with the parent-view, interface, following behind (& in fact fading out).

when I try this I encounter a problem. My animation works fine initially & touchWheel is sent towards the bottom corner, as desired. When touchWheel is about half-way to its destination I animate interface so that it follows touchWheel.

Once interface starts animating it appears to control touchWheel & touchWheel changes course.

It seems that interface still retains control of touchWheel since it's its parent view.

- (void)hideInterfaceButtonClicked : (id) sender
{

    [[NSNotificationCenter defaultCenter] postNotificationName:@"RemoveGrey" object:self];

   //Remove Views & transform
   [touchWheel removeViews];
   interfaceHidden = YES;

      //Send Interface to corner

[UIView animateWithDuration:1.25
                  delay:0.0
                options:UIViewAnimationCurveEaseIn
             animations:^{
                 // Move to the right

                 CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(437,200); 
                 // Scale
                 CGAffineTransform scale = CGAffineTransformMakeScale(0.135,0.135);   

                 // Apply them to the view
                 self.transform = CGAffineTransformConcat(scale, translateInterface);

                self.alpha = 0.0;

             } completion:^(BOOL finished) {
                 NSLog(@"Animation Has Stopped");
                 [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInterfaceViewNeeded" object:self]; //after MoveView finishes


             }]; 



}

Making touchWheel subview of something other than interface creates other problems which would complicate things further.

Any ideas how one might get around this issue? any tips greatly appreciated :)

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Octave1
  • 525
  • 4
  • 19

1 Answers1

2

You could do the following:

  1. Move touchWheel to the interface's superview, recalculating its frame using convertRect:toView: so that touchWheel appears to have the same window coordinates.
  2. Animate both the views to their final locations.
  3. In the completion block of the animation do the opposite of step 1: make touchWheel a subview of interface, recalculating its frame again.

It doesn't seem too complicated, but there's a caveat: you may want to temporarily disable the maximize button (or whatever the appropriate control is) to prevent the maximize action during the animation. Otherwise, this approach will cause unpredictable results.

Costique
  • 23,712
  • 4
  • 76
  • 79