神刀安全网

UIPageViewController、字符串分页

UIPageViewController、字符串分页
横向.gif

UIPageViewController、字符串分页
纵向.gif

上面的效果主要是用到了UIPageViewController,http://www.jianshu.com/p/a676899d9b70 这篇文章讲的挺细的 ,对于中间的图片嵌入效果想了解的可以查看我以前写的内容http://www.jianshu.com/p/a75c1a07cd51

     /*      UIPageViewController 为我们提供了2种翻页样式,一种是拟真,一种是滚动      UIPageViewControllerTransitionStylePageCurl//拟真      UIPageViewControllerTransitionStyleScroll//滚动     翻页的方向      UIPageViewControllerNavigationOrientationHoriz//横向      UIPageViewControllerNavigationOrientationVertical//纵向      */     UIPageViewController * pageVC = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];     pageVC.delegate = self;     pageVC.dataSource = self;     [self addChildViewController:pageVC];     [self.view addSubview:pageVC.view];     //UIPageViewControllerNavigationDirectionForward,//横向,像书一样    //UIPageViewControllerNavigationDirectionReverse//纵向,像日历一样    TextViewController *readerController = [TextViewController alloc] init];//需要展示内容的控制器    [pageVC setViewControllers:@[ readerController ]                                   direction:UIPageViewControllerNavigationDirectionForward                                    animated:YES                                  completion:nil];    #pragma mark -- UIPageViewControllerDelegate,UIPageViewControllerDataSource /*  * 参数ViewController为当前正在显示的VC控制器   return 的ViewController为将要显示的VC控制器  */   //向前翻页执行   - (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{}   //向后翻页时执行   - (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{} //在动画执行完毕后被调用,在controller切换完成后,我们可以在这个代理中进行一些后续操作   - (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(nonnull NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)completed{  }

关于字符串分页想了解的可以去这里了解http://m.blog.csdn.net/article/details?id=10191101

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » UIPageViewController、字符串分页

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址