【问题标题】:iBook Image Curl Animation on iOSiOS 上的 iBook 图像卷曲动画
【发布时间】:2016-08-30 08:53:24
【问题描述】:

我正在开发iPhone 应用程序,其中我有 5-6 组图像。我想使用像iBook 这样的页面卷曲动画来更改图像,其中用户可以根据手指移动和页面卷曲动画滑动页面。我想在 iPhone 上实现相同的动画。有没有办法不使用私有库或UIPageViewController 或者是否有任何可用的示例来实现这一点?

除了谷歌搜索,我还得到了一些库,例如:

树叶

纸叠

XBPagecurl

卷页

没有得到太多帮助。

【问题讨论】:

  • 谢谢安布。我已经调查过了。但这发生在单击具有预定义动画持续时间和时间的按钮时。我希望根据 iBooks 应用程序中实现的用户手指移动来实现此功能。
  • 自定义自己添加手势代码就可以了

标签: ios iphone xcode animation page-curl


【解决方案1】:

像这样在视图中添加滑动手势

UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(curlAnimation)];
[gesture setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view1 addGestureRecognizer:gesture];

使用以下代码sn-p制作卷曲动画

- (void)curlAnimation
{
    [UIView animateWithDuration:1.0
                     animations:^{
                         CATransition  * animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:1.2f];
                         animation.startProgress = 0.0;
                         animation.endProgress   = 1;
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         [animation setType:@"pageCurl"];
                         [animation setSubtype:@"fromRight"];
                         [animation setRemovedOnCompletion:NO];
                         [animation setFillMode: @"extended"];
                         [animation setRemovedOnCompletion: NO];
                         [[self.view1 layer] addAnimation:animation
                                                            forKey:@"pageFlipAnimation"];
                     }
     ];
}

您可以在此方法[animation setSubtype:@"fromRight"]中设置“fromLeft”代替fromRight,用于从左到右制作动画

编码愉快..

【讨论】:

    【解决方案2】:

    请不要寻求确切的解决方案,以上解决方案会给您一些想法,您可以对此进行处理并扩展它。这样你学得越多,玩得越多。我有推荐的博客,请通过它探索它。

    Implement partial and full page curl animation in iOS app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多