【发布时间】:2014-05-19 05:22:45
【问题描述】:
我正在尝试构建一本电子书,翻页(从左到右)和缩放。 到目前为止,我已经测试了几个项目,但没有一个项目能同时做到这两点。 我决定自己做一个,所以我从这样的基本翻转动画开始:
- (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 做到这一点吗?或者更好的选择?
【问题讨论】:
-
嗨,Idan,我被困在了同样的场景中。你能指导一下吗?
标签: ios objective-c animation flip