0

Suppose I have 2 ViewControllers A and B. Properties:

  • A is a rectangle (where its height > its weight)
  • B is a rectangle (where its height > its weight)

I want to do the following process:

  • Turn A into a SMALL (perfect) CIRCLE
  • Move A to the right bottom of the screen, like this:

     ____
    |    |
    |    |
    |    |
    |___O|     about 9/10 of the height and of the width
    

    (both operations can be done at the same time, no problems with that.

To pass A to B, I took a print from A's screen and passed it to B as an UIImage, through a segue.

Then B shows A immediatly. This way I migrate from A to B.

The problem is: How do I turn the A UIImage (rectangular) into a PERFECT CIRCLE and the move to some given position in B (using animateWithDuration)? I couldnt turn it to a perfect circle (using only cornerRadius) and couldn't move it correctly after I make the CGAffineTransformMakeScale operation.

PS: before doing these operations, I turned the UIImage to an UIImageView.

Here is my animation code,

//imageTestte is the UIImageView
self.imageTestte.layer.masksToBounds = TRUE;

_imageTestte.layer.cornerRadius = _imageTestte.bounds.size.width/2;
CGFloat h = _imageTestte.frame.size.height;
CGFloat w = _imageTestte.frame.size.width;
CGRect r = CGRectMake(0, 0, w, w);

[UIView animateWithDuration: 2 delay:0 options:UIViewAnimationOptionCurveLinear  animations:^{
    //_imageTestte.bounds = r;
    //this line above is to turn it to a square
    _imageTestte.transform = CGAffineTransformMakeScale(0.15f, 0.15f);
    _imageTestte.center = CGPointMake(self.view.frame.size.width * (9.0/10.0), self.view.frame.size.height* (9.0/10.0));

} completion:^(BOOL finished) {
}];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Daniel
  • 7,357
  • 7
  • 32
  • 84
  • Why not just one view controller with UIImageView only? If you do want to pass just pass the image name from one to another. imageView.layer.cornerridus = frame.width/2 will make a view circle. – William Hu Sep 14 '16 at 02:19
  • because as I said, A is originally a ViewController, and it has buttons, labels, etc, that cannot be passed to B, so I had to print and pass it as an image – Daniel Sep 14 '16 at 02:36
  • and I tried layer.corneradius = frame.width/2 and all I got was a rectangle that seemed like "half of a circle, a square in between and other half of circle" – Daniel Sep 14 '16 at 02:42
  • did you tried to add maskToBounds = true. How about try find a way add A's view onto B's view then make the view circle? – William Hu Sep 14 '16 at 02:44
  • yes, I used maskToBounds, and I search a lot of ways to pass A to B, one of them was passing the A's view to B through a segue, but on it's way, A's view lost all its components (buttons, labels, etc) – Daniel Sep 14 '16 at 02:46
  • If you can post your transformation and animation code, we can better understand what you are doing. – Aks Sep 14 '16 at 03:05
  • I don't mean pass view just add A's view as B's view's subView http://stackoverflow.com/questions/1486832/how-to-add-an-uiviewcontrollers-view-as-subview – William Hu Sep 14 '16 at 03:38
  • and what do I do with A? I need A to turn into a button in corner of B, A needs to turn into a little ball and move to B's corner (as if it was a B's view) – Daniel Sep 14 '16 at 03:42

0 Answers0