项目引导页并不难,使用 UICollectionView就可以完成,

1.首先获取应用程序的版本号,并存入本地,每次有新版本号,和存入本地的版本号,相比较

 fileprivate func setupRootViewController() {

        window = UIWindow(frame: UIScreen.main.bounds)
print(isNewVersion())
window?.rootViewController = isNewVersion() ? NewFeatureController() : UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
if isNewVersion() {
//此处应该加载用户操作教程
}else {
//此处加载广告页面
loadingAdvertisingPages()
}
window?.makeKeyAndVisible()
} /**
判断是否是新版本
*/
fileprivate func isNewVersion() -> Bool {
// 获取当前的版本号 let versionString = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String let currentVersion = Double(versionString)! // 获取到之前的版本号
let versionKey = "curVersion"
let sandboxVersion = UserDefaults.standard.double(forKey: versionKey) // 保存当前版本号
UserDefaults.standard.set(currentVersion, forKey: versionKey)
UserDefaults.standard.synchronize() // 对比
return currentVersion > sandboxVersion
}

新建一个继承  UICollectionViewController 的类,具体的代码如下

import UIKit

private let reuseIdentifier = "Cell"

class NewFeatureController: UICollectionViewController {
fileprivate let itemCount = fileprivate var layout = UICollectionViewFlowLayout()
//MARK: - 系统回调函数
override func viewDidLoad() {
super.viewDidLoad() self.collectionView!.register(NewFeatureCell.self, forCellWithReuseIdentifier: reuseIdentifier)
self.collectionView?.isPagingEnabled = true
self.collectionView?.bounces = false
self.collectionView?.showsHorizontalScrollIndicator = false
self.collectionView?.backgroundColor = UIColor.white
layout.scrollDirection = UICollectionViewScrollDirection.horizontal layout.minimumLineSpacing =
layout.minimumInteritemSpacing =
layout.itemSize = UIScreen.main.bounds.size
} init() {
super.init(collectionViewLayout:layout)
} required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
} override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} } // MARK: UICollectionViewDataSource
extension NewFeatureController { override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return itemCount
} override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! NewFeatureCell cell.imageIndex = String(indexPath.item)
cell.setIndexPath(indexPath: indexPath, count: itemCount)
return cell } }
import UIKit

class NewFeatureCell: UICollectionViewCell {

    //MARK: - 懒加载属性
fileprivate lazy var imageView: UIImageView = UIImageView() fileprivate lazy var startButton: UIButton = UIButton()
var imageName: String? var imageIndex: String? { didSet { let screenH = UIScreen.main.bounds.height //加载不同的图片
if screenH == {
imageName = imageIndex!+"welcome1136"
}else if screenH == {
imageName = imageIndex!+"welcome1334"
}else {
imageName = imageIndex!+"welcome1472"
} imageView.image = UIImage(named: imageName!) }
} //MARK: - 构造函数 override init(frame: CGRect) {
super.init(frame: frame) setupUI()
} required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
} } //MARK: - 设置 UI界面相关
extension NewFeatureCell { fileprivate func setupUI() { startButton.setTitle("开始全新体验", for: .normal)
startButton.setTitleColor(UIColor.orange, for: .normal)
startButton.sizeToFit()
startButton.isHidden = true
startButton.addTarget(self, action: #selector(NewFeatureCell.startBtnClick), for: .touchUpInside)
self.contentView .addSubview(imageView)
self.contentView.addSubview(startButton) } //布局子控件的 frame
override func layoutSubviews() {
super.layoutSubviews()
imageView.frame = self.bounds startButton.center = CGPoint(x: self.bounds.width * 0.5, y: self.bounds.height * 0.9)
} func setIndexPath(indexPath: IndexPath, count: Int) {
if indexPath.item == count- {
startButton.isHidden = false
}else {
startButton.isHidden = true
}
} } //MARK: - 事件的点击
extension NewFeatureCell { @objc fileprivate func startBtnClick() {
UIApplication.shared.keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() }
}

swift3.0 项目引导页的更多相关文章

  1. Swift3.0项目学习: 创建撰写按钮

    import UIKit class PSMainViewController: UITabBarController { override func viewDidLoad() { super.vi ...

  2. 用Flutter开发的跨平台项目,完美运行在Android和IOS上,Material简洁风格,包括启动页、引导页、注册、登录、首页、体系、公众号、导航、项目,还有漂亮的妹子图库,运行极度流畅,结构清晰,代码规范,值得拥有

    Flutter学习资源汇总持续更新中...... Flutter官方网站 Flutter中文网 wendux的Flutter实战 Flutter官方exampleflutter_gallery 阿里巴 ...

  3. swift3.0 创建一个app引导页面

    swift毕竟不像是oc ,第三方的框架很多,更何况是3.0,自己动手写了个引导页面,看得上我代码的麻友可以拿去用 引导页面有三个部分构成,scrollview用语切换引导视图,pageControl ...

  4. Android项目实战(三):实现第一次进入软件的引导页

    最近做的APP接近尾声了,就是些优化工作了, 我们都知道现在的APP都会有引导页,就是安装之后第一次打开才显示的引导页面(介绍这个软件的几张可以切换的图) 自己做了一下,结合之前学过的 慕课网_Vie ...

  5. android 项目学习随笔二(引导页 )

    1.引导页 1.定义灰色.红色圆点的shape XML文件 2.定义布局文件,利用相对布局文件定位,利用线性布局加载灰色圆点,imageview加载红色圆点 3.android.support.v4. ...

  6. Android 引导页公共方法LeaderPager

    SimpAndroidFarme是近期脑子突然发热想做的android快速开发的框架,目标是模块化 常用的控件,方便新手学习和使用.也欢迎老鸟来一起充实项目:项目地址 引导页是我们开发app很常用的功 ...

  7. Xamarin.Android之引导页的简单制作

    0x01 前言 对于现在大部分的APP,第一次打开刚安装或更新安装的APP都会有几个引导界面,通常这几个引导页是告诉用户 APP有些什么功能或者修改了什么bug.新增了什么功能等等等. 下面就用Xam ...

  8. iOS 引导页组件 HcdGuideView

    HcdGuideView HcdGuideView让你为你的app添加一个漂亮的启动页变得简单. 要求 Xcode 6 or higher iOS 7.0 or higher ARC 安装方法 手动安 ...

  9. iOS最好用的引导页

    最近项目结束的时候又要改引导页,之前写的启动页改起来太麻烦了,所以就直接封装一个,功能可能还不是很完善,但是感觉用起来也比较方便,在这里和大家分享一下. 这是github的下载地址:https://g ...

随机推荐

  1. windwos 10 谷歌浏览器出现彩色闪条

    应该是上个星期五开始,发现电脑从别的地方切换到谷歌浏览器就会出现闪条,开始也没太注意,但是到周一还是这样,所以再网上查了下, 说什么的都有,什么你按脑屏幕坏了,内存条不行什么是的.后来才发现原来是谷歌 ...

  2. lsnrctl启动报错,Linux Error: 29: Illegal seek

    [oracle@phydb admin]$ lsnrctl startLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-SEP-2014 ...

  3. poj3208启示录——数位DP

    题目:http://poj.org/problem?id=3208 数位DP,首先按位数预处理出每一种位数的情况,包括有多少个魔鬼数和有多少个以6开头的非魔鬼数,以便递推.累加等等: 然后先找出第X个 ...

  4. 南阳oj水题集合,语言的灵活运用

    a+b 输入 输入两个数,a,b 输出 输出a+b的值 样例输入 2 3 样例输出 5 c/c++ #include<iostream> using namespace std; int ...

  5. SQL 调用 webservice

    webservice 需要配置为get 方式 sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ole ...

  6. [xdoj1227]Godv的数列(crt+lucas)

    解题关键:1001=7*11*13,模数非常小,直接暴力lucas.递归次数几乎为很小的常数.最后用中国剩余定理组合一下即可. 模数很小时,一定记住lucas定理的作用 http://acm.xidi ...

  7. [hdu4812]D Tree(点分治)

    题意:问有多少条路径,符合路径上所有节点的权值乘积模1000003等于k. 解题关键:预处理阶乘逆元,然后通过hash和树形dp$O(1)$的判定乘积存在问题,注意此道题是如何处理路径保证不重复的,具 ...

  8. hdu2732 Leapin' Lizards (网络流dinic)

    D - Leapin' Lizards Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  9. Insert into a Binary Search Tree

    Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert t ...

  10. 剑指Offer的学习笔记(C#篇)-- 数组中重复的数字

    题目描述 在一个长度为n的数组里的所有数字都在0到n-1的范围内. 数组中某些数字是重复的,但不知道有几个数字是重复的.也不知道每个数字重复几次.请找出数组中任意一个重复的数字. 例如,如果输入长度为 ...