VXWalkthroughViewController
VXWalkthroughViewController 是一个简单的方式来为您的应用添加引导。按步骤向用户展示您应用的主要功能。您的入职教程可以包括文本、图像甚至是简单的 HTML。
VXWalkthroughViewController 功能
- 易于集成
- 使用现有的本地化设置进行配置
- 支持图像
- 支持 iPhone 和 iPad
安装
CocoaPods
如果您想在 CocoaPods 中使用 VXWalkthroughViewController,请使用 pod 'VXWalkthroughViewController', :head
手动
- 将
VXWalkthroughViewController/VXWalkthroughViewController
文件夹拖入您的项目中。 #import "VXWalkthroughViewController.h"
使用方法
(参见 /Demo
目录中的示例 Xcode 项目)
在您的 Localizable.strings
文件中添加一些步骤,以便可以使用 NSLocalizedString 寻找它们。您可以添加任意多的步骤,但请从 0 开始并使它们无步骤。如果您需要图片,请使用预定的名称(如 walkthrough_0.png
、walkthrough_1.png
等)将它们添加到项目中。
"walkthrough_0" = "See No Evil";
"walkthrough_1" = "Hear No Evil";
"walkthrough_2" = "Speak No Evil";
检查您是否应该在 viewDidload
中显示引导
if(![VXWalkthroughViewController walkthroughShown]) {
// this is to avoid timing issues
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// show the walkthrough
[self showWalkthrough];
});
}
使用便捷方法 VXWalkthroughModalViewController
是最简单的办法
- (void)showWalkthrough{
UIColor *backgroundColor = [UIColor colorWithRed:167.0f/255.0f green:131.0f/255.0f blue:82.0f/255.0f alpha:1.0f];
// create the walkthough controller
VXWalkthroughViewController* walkthrough = [VXWalkthroughViewController initWithDelegate:self withBackgroundColor:backgroundColor];
// show it
[self presentViewController:walkthrough animated:YES completion:nil];
}
-(void)walkthroughCloseButtonPressed:(id)sender{
// delegate for handling close button
[self dismissViewControllerAnimated:YES completion:nil];
}
发行说明
1.0.17
iOS 13 的小范围修复
1.0.16
添加了任务特定页面视图控制器(例如:登录、注册、操作等)以及登录页面视图扫描 QR 码的选项
1.0.15
IOS 11 的修复
1.0.12
改进了不同方向上的启动处理。一旦启动,就会锁定旋转以防止显示问题。在 Xcode 7.2.1 下重新编译并修复了警告
1.0.11
实现了控制和动态修改教程屏幕群体的选项。示例显示了自动初始化的群体和图像修改(更适合)
[walkthrough populate];
NSString *key = @"walkthrough_1";
NSMutableDictionary* item = [[walkthrough.items valueForKey:key] mutableCopy];
if(item) {
NSString* imageName = [[self.categories firstObject] imageName];
if(imageName) {
[item setValue:imageName forKey:@"image"];
[walkthrough.items setObject:item forKey:key];
}
}
1.0.10
实现了 Jay Lyerly 的建议,增加了使用全屏图像的选项
walkthrough.roundImages = NO;
鸣谢
VXWalkthroughViewController 基于 Yari D'areglia 的 BWWalkthrough 和 Sam Vermettes 的 SVWebViewController。VXWalkthroughViewController 由 Swift Management AG 和 项目贡献者 提供。如果您有任何功能建议或错误报告,请通过发送 pull request 或通过 创建新问题 来帮助。如果您在项目中使用 VXWalkthroughViewController,鸣谢是被赞赏的。