2016-09-21 47 views
3

我正在尋找一種方法來指示uiview上的一個pagecurl動畫,以提示用戶可以滾動瀏覽某些頁面的提示。它應該是某種部分的pagecurl。用swift部分pagecurl動畫

問題是我不知道該怎麼做。我發現了一些教程,但只針對目標c和我不知道如何將其轉移到SWIFT:

[UIView animateWithDuration:1.0 
        animations:^{ 
         CATransition * animation = [CATransition animation]; 
         [animation setDuration:1.2f]; 
         animation.startProgress = 0.0; 
         animation.endProgress = 0.6; 
         [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
         [animation setType:@"pageCurl"]; 
         [animation setSubtype:@"fromRight"]; 
         [animation setRemovedOnCompletion:NO]; 
         [animation setFillMode: @"extended"]; 
         [animation setRemovedOnCompletion: NO]; 
         [[self.animatedUIView layer] addAnimation:animation 
                 forKey:@"pageFlipAnimation"]; 
          [self.animatedUIView addSubview:tempUIView]; 

        } 
    ]; 

http://www.iostute.com/2015/04/how-to-implement-partial-and-full-page.html

回答

0

我認爲你可以使用UIPageViewController。 我爲我的項目做了這樣的事情。本教程很有幫助。

https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/

+0

我已經這樣做了。現在,我想在第一頁上提供類似傳情的內容,以向用戶顯示有更多網頁可供使用,並且可以滾動瀏覽。就像右下角稍微卷起一點。 – Patricks

+0

我聽到你的聲音。我在我的項目中實現這一點的方式我使用帶捲曲圖像背景的UIButton,當用戶按下該按鈕時,它將觸發捲曲動畫。 – rohit90

4

夫特3;

UIView.animate(withDuration: 1.0, animations: { 
    let animation = CATransition() 
    animation.duration = 1.2 
    animation.startProgress = 0.0 
    animation.endProgress = 0.6 
    animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) 
    animation.type = "pageCurl" 
    animation.subtype = "fromRight" 
    animation.isRemovedOnCompletion = false 
    animation.fillMode = "extended" 
    self.animatedUIView.layer.add(animation, forKey: "pageFlipAnimation") 
    self.animatedUIView.addSubview(tempUIView) 
}) 

夫特2;

UIView.animateWithDuration(1.0, animations: { 
    let animation = CATransition() 
    animation.duration = 1.2 
    animation.startProgress = 0.0 
    animation.endProgress = 0.6 
    animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) 
    animation.type = "pageCurl" 
    animation.subtype = "fromRight" 
    animation.removedOnCompletion = false 
    animation.fillMode = "extended" 
    self.animatedUIView.layer.addAnimation(animation, forKey: "pageFlipAnimation") 
    self.animatedUIView.addSubview(tempUIView) 
})