Swift小练习-引导页
任何一门语言,只要长期不用就会忘掉,得时不时的敲敲小项目,练练手;
let scrollViewBG = UIScrollView.init(frame: SLScreenRect)
let images = ["first","second","third"]
let pageControl = UIPageControl.init(frame: CGRect.init(x: 0, y: SLScreenHeight - 30, width: SLScreenWidth, height: 20))
var currentPage = 0
override var prefersStatusBarHidden: Bool {
return true
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
configureView()
}
func configureView() {
// 遍历数组,同时获得index
for (index, value) in images.enumerated() {
let imageView = UIImageView.init(frame: CGRect.init(x: CGFloat(index)*SLScreenWidth, y: 0, width: SLScreenWidth, height: SLScreenHeight))
imageView.image = UIImage.init(named: value)
// 限制边界
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
scrollViewBG .addSubview(imageView)
}
// 协议
scrollViewBG.delegate = self
scrollViewBG.isPagingEnabled = true
scrollViewBG.showsHorizontalScrollIndicator = false
scrollViewBG.contentSize = CGSize.init(width: SLScreenWidth*CGFloat(images.count), height: SLScreenHeight)
// pagecontol
pageControl.numberOfPages = images.count
pageControl.currentPageIndicatorTintColor = .white
pageControl.pageIndicatorTintColor = .lightGray
pageControl.currentPage = currentPage
pageControl.isEnabled = false
view.addSubview(scrollViewBG)
view.addSubview(pageControl)
}
//MARK: - 协议方法
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
currentPage = Int(scrollView.contentOffset.x/SLScreenWidth)
pageControl.currentPage = currentPage
}

Swift小练习-引导页的更多相关文章
- [iOS] App引导页的简单实现 (Swift 2)
转载请注明出处:http://www.jianshu.com/p/024dd2d6e6e6# 已更新至 Xcode7.2.Swift2.1 在第一次打开App或者App更新后通常用引导页来展示产品特性 ...
- [iOS]简单的APP引导页的实现 (Swift)
在第一次打开APP或者APP更新后通常用引导页来展示产品特性 我们用NSUserDefaults类来判断程序是不是第一次启动或是否更新,在AppDelegate.swift中加入以下代码: func ...
- iOS开发笔记(Swift)-通用App安装引导页的实现
之前一直做的项目都是基于OC开发的,最近开始尝试使用Swift语言来重写整个项目. 本篇文章主要是讲述如何使用Swift来实现常见的通用App安装引导界面. 效果预览: 实现思路: 主要是采用了UIS ...
- [Swift通天遁地]九、拔剑吧-(15)搭建具有滑出、视差、3D变形等切换效果的引导页
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- iOS帅气加载动画、通知视图、红包助手、引导页、导航栏、朋友圈、小游戏等效果源码
iOS精选源码 如丝般顺滑的微信朋友圈(点赞,评论,图文混排表情,... 动态菜单第三版本:动态项,自适应方向 仿appstore首页滚动效果 iOS 透明导航栏方案 TransparentNavig ...
- IOS开发小功能1:引导页的开发
效果图如上,实现的是一个页面引导页,最后跳到主页面,主页面是一个navigationController,但是导航栏给我隐藏了. 文件目录:自己定制的viewcontroller以及navigatio ...
- iOS_开发中引导页的设置及代码
在iOS 手机App 软件的开发中, 基本上每一个完整的App 都有与之相对应的引导页的设置,引导页也会有很多种设置的方式,根据不同的情况,选择不同的编码,在这里,我分享一下自己关于引导页的一些看法和 ...
- Android引导页设计
大家在安装好一个应用后,第一次打开时往往会出现一个使用引导页,形式一般为三.四张图片,随着我们的滑动进行切换,在最后一页会有一个进入应用的按钮,我们通过点击这个按钮可以进入应用,其实这其中没有太多的复 ...
- 如何做好App的引导页?(转)
http://uedc.163.com/12264.html 当你第一次打开一款应用的时候常常会看到精美的引导页设计,它们在你未使用产品之前提前告知你产品的主要功能与特点,第一次印象的好坏会极大地影响 ...
随机推荐
- C#版BitStream 1.0
根据C++版的改编,刚刚改完,估计使用会有问题,对于uint8处理的不好 关于使用: BitStream bs = new BitStream( ); bs.WriteInt32( ); int a ...
- c++ 陷阱
.c89 c90 gnu90 c99 c11 c++98( default ) c++03 c++11 gnu++11 boolC 标准 does not support the boolean da ...
- mysql 基础使用
mysql服务器本地root用户默认没有密码,使用 "mysql -u root -p" 即可登陆.linux本地用户可以以任意用户名登陆mysql,但是没有任何权限,没有意义.m ...
- cxf WebService设置wsdl中soapAction的值
用cxf开发一个WebService很简单,只需要下面几步: 1.定义接口 public interface HelloService { String hello(); } 2.实现 public ...
- h5手机页面禁止缩放
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable= ...
- 相机变换与Ray-Casting
p { margin-bottom: 0.1in; direction: ltr; line-height: 120%; text-align: justify; orphans: 0; widows ...
- 7.iOS Notification
1. 通知中心认识 通知中心实际上是在程序内部提供了消息广播的一种机制.通知中心不能在进程间进行通信,它只能进行程序内部通信,不能跨应用程序进程通信.通知中心,当通知中心接受到消息后会根据设置,根据内 ...
- R3.2.2安装
- Python的方法解析顺序(MRO)
mro即method resolution order,主要用于在多继承时判断调的属性的路径(来自于哪个类). http://blog.csdn.net/imzoer/article/details/ ...
- LeetCode 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels(元音字母) of a string. Example ...