TDBWalkthrough是一个允许在应用程序启动时添加引导的pod。
TDBWalkthrough可以通过CocoaPods安装,只需将以下行添加到您的Podfile中
pod 'TDBWalkthrough'
要运行示例项目,请执行pod try TDBWalkthrough
。或者手动方式:克隆存储库,从Example目录运行pod install
,打开工作区。
以下是如何使用TDBWalkthrough的示例
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UIViewController *viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = viewController;
TDBWalkthrough *walkthrough = [TDBWalkthrough sharedInstance];
NSArray *images = [NSArray arrayWithObjects:
[UIImage imageNamed:@"first.png"],
[UIImage imageNamed:@"second.png"],
[UIImage imageNamed:@"third.png"],
[UIImage imageNamed:@"fourth.png"], nil];
NSArray *descriptions = [NSArray arrayWithObjects:
@"Find all the electronic music events around you",
@"Filter by cost, date and genre to get relevant results",
@"Get all the details for every events in your city",
@"Follow artists to get accurate suggestions in the future",
nil];
walkthrough.descriptions = descriptions;
walkthrough.images = images;
walkthrough.className = @"TDBSimpleWhite";
walkthrough.nibName = @"TDBSimpleWhite";
walkthrough.delegate = self;
//page control
UIPageControl *pc = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 518, 120, 30)];
pc.numberOfPages = 4;
pc.currentPage = 0;
pc.pageIndicatorTintColor = [UIColor lightGrayColor];
pc.currentPageIndicatorTintColor = [UIColor darkGrayColor];
walkthrough.walkthroughViewController.pageControl = pc;
[walkthrough.walkthroughViewController.view addSubview:walkthrough.walkthroughViewController.pageControl];
[walkthrough show];
return YES;
}
您还可以使用不同的动画隐藏启动屏幕
[TDBWalkthrough dismissWithAnimation:UIModalTransitionStyleCrossDissolve];
您还可以添加一个完成处理程序,在启动屏幕隐藏后执行代码
[TDBWalkthrough dismissWithAnimation:UIModalTransitionStyleCrossDissolve completion:^{
// Splashscreen has been dismissed
}];
Titouan Van Belle,[email protected]
TDBWalkthrough遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。