LAWalkthrough是为iOS设计的视图控制器类,旨在简化walkthrough设计模式的创建。此代码于2013年4月受到Mari Sheibley在http://www.mobile-patterns.com/walkthroughs上显示的屏幕截图的启发。
它使用起来很简单,并且实现一个看起来不错的walkthrough需要非常少的代码。它使用UIPageControl和UIScrollView,并且易于子类化进行定制。
// Create the walkthrough view controller
LAWalkthroughViewController *walkthrough = LAWalkthroughViewController.new;
walkthrough.view.frame = self.view.frame;
walkthrough.backgroundImage = [UIImage imageNamed:@"tour-bg@2x"];
// Create pages of the walkthrough
[walkthrough addPageWithBody:@"Take a tour of this app."];
[walkthrough addPageWithBody:@"Thanks for taking this tour."];
// Use the default next button
walkthrough.nextButtonText = nil;
// Add the walkthrough view to your view controller's view
[self addChildViewController:walkthrough];
[self.view addSubview:walkthrough.view];
// Create the walkthrough view controller
LAWalkthroughViewController *walkthrough = LAWalkthroughViewController.new;
walkthrough.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-50);
walkthrough.backgroundImage = [UIImage imageNamed:@"tour-bg1@2x"];
// Create pages of the walkthrough from XIBs
[walkthrough addPageWithNibName:@"TourView1" bundle:nil]; // no need for a view controller
[walkthrough addPageWithNibName:@"TourView2" bundle:nil]; // no need for a view controller
[walkthrough addPageWithNibName:@"TourView3" bundle:nil]; // no need for a view controller
// Use text for the next button
walkthrough.nextButtonText = @"Next >";
// Add the walkthrough view to your view controller's view
[self addChildViewController:walkthrough];
[self.view addSubview:walkthrough.view];
从LAWalkthrough 1.0开始需要iOS 6.0以上。
自1.0版发布以来,LAWalkthrough使用ARC。
如果您正在您的非ARC项目中使用LAWalkthrough 1.0,您需要在所有LAWalkthrough源文件上设置一个-fobjc-arc
编译器标志。
要在Xcode中设置编译器标志,请转到您的活动目标并选择“构建阶段”选项卡。现在选择所有LAWalkthrough源文件,按Enter,插入-fobjc-arc
或-fno-objc-arc
,然后“完成”以启用或禁用LAWalkthrough的ARC。
LAWalkthrough是在开发Konugo for iPhone时由Larry Aasen创建的。
在Twitter上关注LAWalkthrough和Konugo (@Konugo)
LAWalkthrough采用MIT许可证发布。更多信息请参阅LICENSE文件。