介绍视图
它会显示一个全屏的可滑动模态窗口,引导用户通过欢迎屏幕/教程
// data source
self.coverImageNames = ["img_index_01txt","img_index_02txt", "img_index_03txt"]
self.backgroundImageNames = ["img_index_01bg","img_index_02bg", "img_index_03bg"]
self.coverTitles = ["MAKE THE WORLD", "THE BETTER PLACE"]
let filePath = NSBundle.mainBundle().pathForResource("intro_video", ofType: "mp4")
self.videoURL = NSURL.fileURLWithPath(filePath!)
// Added Introduction View
// self.introductionView = self.simpleIntroductionView()
// self.introductionView = self.coverImagesIntroductionView()
// self.introductionView = self.customButtonIntroductionView()
self.introductionView = self.videoIntroductionView();
// self.introductionView = self.advanceIntroductionView();
self.window?.addSubview(self.introductionView)
self.introductionView!.didSelectedEnter = {
self.introductionView!.removeFromSuperview()
self.introductionView = nil;
// enter main view , write your code ...
}
// Example 1 : Simple
func simpleIntroductionView() -> ZWIntroductionView {
let vc = ZWIntroductionView(coverImageNames: self.backgroundImageNames)
return vc
}
// Example 2 : Cover Images
func coverImagesIntroductionView() -> ZWIntroductionView {
let vc = ZWIntroductionView(coverImageNames: self.coverImageNames, backgroundImageNames: self.backgroundImageNames)
return vc
}
// Example 3 : Custom Button
func customButtonIntroductionView() -> ZWIntroductionView {
let enterButton = UIButton()
enterButton.setBackgroundImage(UIImage(named: "bg_bar"), forState: .Normal)
enterButton.setTitle("Login", forState: .Normal)
let vc = ZWIntroductionView(coverImageNames: self.coverImageNames, backgroundImageNames: self.backgroundImageNames, button: enterButton)
return vc
}
// Example 4 : Video
func videoIntroductionView() -> ZWIntroductionView {
let vc = ZWIntroductionView(video: self.videoURL)
vc.coverImageNames = self.coverImageNames
vc.autoScrolling = true
return vc
}
// Example 5 : Advance
func advanceIntroductionView() -> ZWIntroductionView {
let loginButton = UIButton(frame: CGRectMake(3, self.window!.frame.size.height - 60, self.window!.frame.size.width - 6, 50))
loginButton.backgroundColor = UIColor.init(white: 1, alpha: 0.5)
loginButton.setTitle("Login", forState: .Normal)
let vc = ZWIntroductionView(video: self.videoURL, volume: 0.7)
vc.coverImageNames = self.coverImageNames
vc.autoScrolling = true
vc.hiddenEnterButton = true
vc.pageControlOffset = CGPointMake(0, -100)
vc.labelAttributes = [NSFontAttributeName: UIFont(name: "Arial-BoldMT", size: 28.0)!,
NSForegroundColorAttributeName: UIColor.whiteColor()]
vc.coverView = loginButton
vc.coverTitles = self.coverTitles
return vc
}
// data source
self.coverImageNames = @[@"img_index_01txt", @"img_index_02txt", @"img_index_03txt"];
self.backgroundImageNames = @[@"img_index_01bg", @"img_index_02bg", @"img_index_03bg"];
self.coverTitles = @[@"MAKE THE WORLD", @"THE BETTER PLACE"];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"intro_video" ofType:@"mp4"];
self.videoURL = [NSURL fileURLWithPath:filePath];
// Added Introduction View
// self.introductionView = [self simpleIntroductionView];
// self.introductionView = [self coverImagesIntroductionView];
// self.introductionView = [self customButtonIntroductionView];
self.introductionView = [self videoIntroductionView];
// self.introductionView = [self advanceIntroductionView];
[self.window addSubview:self.introductionView];
__weak AppDelegate *weakSelf = self;
self.introductionView.didSelectedEnter = ^() {
[weakSelf.introductionView removeFromSuperview];
weakSelf.introductionView = nil;
};
查看示例项目以了解如何使用更多的自定义功能
本项目包含一个用于 CocoaPods 的 podspec
。只需将以下内容添加到您的 Podfile
中,然后运行 pod install
。
pod 'ZWIntroductionViewController'
或者,您可以将本项目的 Library
目录中包含的所有文件添加到您的 Xcode 项目中。如果您的项目不使用 ARC,您需要为这些文件启用 ARC。您可以通过添加 -fobjc-arc 标志在单个文件上启用 ARC,如常见 StackOverflow 问题所述。
许可协议
版权所有 (c) 2015 Square
任何人获取本软件及其相关文档文件(“软件”)的副本,免费获得以下权利,在不限制的前提下使用软件,包括但不限于以下权利:使用、复制、修改、合并、发布、分发、再许可和/或出售软件的副本,并允许向软件提供方的用户提供此行为。
在本软件的所有副本或主要部分中应包含上述版权声明和本许可声明。
软件按“原样”提供,无论明示或暗示,不提供任何保证,包括但不限于适销性、针对特定用途的适用性和非侵权性。在任何情况下,作者或版权持有人均不对任何索赔、损害或其他任何责任负责,无论是对合同、侵权或其他方式而产生的。
本软件是根据苹果公司 Xcode 项目协议中定义的许可协议提供的。本软件可能还包括受其他许可证约束的软件组件。使用本软件前,您必须遵守苹果公司 Xcode 项目协议中的条款,以及任何其他适用的许可证协议。有关更多信息,请参阅苹果公司 Xcode 项目协议和许可证协议。