Reputation: 769
I'm looking for a way to indicate a pagecurl animation on an uiview to give the user a hint that he can scroll through some pages. It should be some kind of partial pagecurl.
The problem is that I don't know how to do that. I found some tutorials but only for objective c and I don't know how transfer it into 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
Upvotes: 5
Views: 4156
Reputation: 527
For your help I have uppdatedt the same code to the latest version
UIView.animate(withDuration: 1.0, animations: {
let animation = CATransition()
animation.duration = 1.2
animation.startProgress = 0.0
animation.endProgress = 0.6
animation.type = CATransitionType(rawValue: "pageCurl")
animation.subtype = CATransitionSubtype(rawValue: "fromRight")
animation.isRemovedOnCompletion = false
animation.fillMode = CAMediaTimingFillMode(rawValue: "extended")
animation.isRemovedOnCompletion = false
if let animation = animation as? CATransition{
self.view.layer.add(animation, forKey: "pageFlipAnimation")
self.viewDidLoad()
}
self.view.addSubview(self.TableView)
})
Upvotes: 2
Reputation: 1658
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)
})
Upvotes: 8
Reputation: 173
I think you can use UIPageViewController. I did something like this for my project. This tutorial is helpful.
https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/
Upvotes: 0