YZSwipeBetweenViewController 0.1.0

YZSwipeBetweenViewController 0.1.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布最后发布2017年12月
SwiftSwift 版本3.0

Yichi Zhang 维护。



  • Yichi Zhang

一个视图控制器,其中包含一个滚动视图,该视图包含多个视图控制器的视图;用户可以左右滑动以切换到不同的视图。

Screenshot

安装

只需使用 CocoaPods

pod 'YZSwipeBetweenViewController'

使用

简单使用

@property (strong) YZSwipeBetweenViewController *swipeBetweenVC;

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    self.swipeBetweenVC = [YZSwipeBetweenViewController new];

    UIViewController *vc1 = [DemoMainViewController new];
    UINavigationController *navCon1 =
    [[UINavigationController alloc]initWithRootViewController:vc1];

    UIViewController *vc2 = [DemoMainViewController new];
    UINavigationController *navCon2 =
    [[UINavigationController alloc] initWithRootViewController:vc2];

    UIViewController *vc3 = [DemoMainViewController new];
    UINavigationController *navCon3 =
    [[UINavigationController alloc] initWithRootViewController:vc3];

    self.swipeBetweenVC.viewControllers = @[navCon1, navCon2, navCon3];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor blackColor];
    [self.window setRootViewController:self.swipeBetweenVC];
    [self.window makeKeyAndVisible];

    return YES;
}

您可以更改视图控制器

self.swipeBetweenVC.viewControllers = newViewControllers;
[self.swipeBetweenVC reloadViewControllers];

滚动到索引为的视图控制器

//Switch to the first view controller
[self.swipeBetweenVC scrollToViewControllerAtIndex:0 animated:YES];

//Switch to the second view controller
[self.swipeBetweenVC scrollToViewControllerAtIndex:1 animated:YES];

//Switch to the third view controller
[self.swipeBetweenVC scrollToViewControllerAtIndex:2 animated:YES];