0

I'm trying to add a flip animation to an UIImageView in Xamarin. The flip animation does work, however, it flips the entire root view. I only want the UIImageView to flip, not the entire screen. Here's what I have:

    back = new UIImageView(UIImage.FromBundle("CardBack.jpg"));
    back.UserInteractionEnabled = true;
    back.Frame = new RectangleF(110, 20, 100, 100);
    RootView.AddSubview(back);

    front = new UIImageView(UIImage.FromBundle("jack.jpg"));
    front.Frame = new RectangleF(110, 20, 100, 100);

The transition code, which occurs when the user touches the image, is as followed:

    UIImageView.Transition(
        fromView: back,
        toView: front,
        duration: .5,
        options: UIViewAnimationOptions.TransitionFlipFromTop | UIViewAnimationOptions.CurveEaseInOut,
            completion: () => { Console.WriteLine("transition complete"); });

How would I just flip the UIImageView, rather than the entire UIView?

  • I don’t know Xamarin.. but for Objective-C you can check http://phildow.net/2012/05/31/flip-an-image-in-uiimageview-using-uiview-transitionwithview/ or http://stackoverflow.com/questions/9656071/how-to-flip-a-uiview-around-the-x-axis-while-simultaneously-switching-subviews – TonyMkenu Aug 12 '14 at 12:55

2 Answers2

0

[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^(void) { imageview.transform = CGAffineTransformMakeScale(1, -1); } completion:nil];

Mini
  • 203
  • 1
  • 5
0

You can use this code for flip animation on your imageview

[UIView beginAnimations:@"bucketsOff" context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationDelegate:(id)self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.ImageView cache:YES];
//animate off screen
[UIView commitAnimations];

AnimationTransition types are:

typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,

};

BHASKAR
  • 1,201
  • 1
  • 9
  • 20