簡體   English   中英

將翻轉動畫添加到UIImageView

[英]Adding Flip Animation to UIImageView

我試圖在Xamarin中將翻轉動畫添加到UIImageView中。 翻轉動畫確實起作用,但是,它將翻轉整個根視圖。 我只希望UIImageView翻轉,而不是整個屏幕。 這是我所擁有的:

    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);

當用戶觸摸圖像時發生的過渡代碼如下:

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

我將如何翻轉UIImageView,而不是整個UIView?

[UIView animateWithDuration:0.5延遲:0.0選項:UIViewAnimationOptionCurveEaseInOut動畫:^(void){imageview.transform = CGAffineTransformMakeScale(1,-1); }完成:無];

您可以使用此代碼在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類型為:

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

};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM