簡體   English   中英

從中間動畫UIImageView翻轉

[英]Animating UIImageView flip from middle

我正在嘗試建立電子書,翻頁(從左到右)並縮放。 到目前為止,我已經測試了一些項目,但是它們都不足以同時完成這兩個項目。 我決定構建自己的一個,所以我從這樣的基本翻轉動畫開始:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.scrollView.delegate = self;
    self.scrollView.maximumZoomScale = 5.0f;

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    tapGesture.delegate = self;
    tapGesture.numberOfTapsRequired = 1;
    tapGesture.numberOfTouchesRequired = 1;
    [self.scrollView addGestureRecognizer:tapGesture];
}

#pragma mark - UIScrollView Delegate

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageView;
}

#pragma mark - UIGestureRecognizer Delegate

- (void)handleTap:(UITapGestureRecognizer *)tapGestur
{
    NSLog(@"%s", __PRETTY_FUNCTION__);

    if (tapGestur.state == UIGestureRecognizerStateEnded) {

        [UIView transitionWithView:self.imageView duration:1 options:UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionCurveEaseInOut animations:^{
            if (!flipped) {
                self.imageView.image = [UIImage imageNamed:@"2-IPAD-P.jpg"];
                flipped = YES;
            }
            else {
                self.imageView.image = [UIImage imageNamed:@"1-IPAD-P.jpg"];
            }
        } completion:^(BOOL finished) {
            //
        }];
    }
}

我現在想做的是從圖像中間過渡翻轉頁面(從左到右)。 知道如何使用UIVIew做到這一點嗎? 還是更好的選擇?

您還應該看看CATansition 這個例子

另外,您是否查看過UIViewAnimationOptions的UIViewAnimationOptionTransitionCurlUpUIViewAnimationOptionTransitionCurlDown用於頁面動畫?

暫無
暫無

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

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