Swift 菊花、UIPageControl和UIProgressView
// Make: 加载 菊花
func _initUIActivityIndicatorView() {
let activity = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White)
activity.frame = CGRect(x: 100, y: 100, width: 50, height: 50)
activity.backgroundColor = UIColor.blueColor()
//开始转动
activity.startAnimating()
//停止转动并且隐藏
// activity.stopAnimating()
self.view.addSubview(activity)
}
// Make: 页码控制器
func _initPageControl() {
let pageControl = UIPageControl(frame: CGRect(x: 100, y: 200, width: 100, height: 20))
pageControl.backgroundColor = UIColor.blueColor()
//设置总页数
pageControl.numberOfPages = 3
//设置当前选中的页数,从0开始
pageControl.currentPage = 2
//添加点击事件
pageControl.addTarget(self, action: "pageAction:", forControlEvents: UIControlEvents.ValueChanged)
self.view.addSubview(pageControl)
}
func pageAction(pageControl: UIPageControl) {
print("currentPage is \(pageControl.currentPage)")
}
// Make: 进度条
func _initProgress() {
let progress = UIProgressView(progressViewStyle: UIProgressViewStyle.Default)
//设置进度值(0-1)
progress.progress = 1
//设置已经加载的进度条的颜色
progress.progressTintColor = UIColor.orangeColor()
//设置未加载的进度条的颜色
progress.trackTintColor = UIColor.blueColor()
progress.frame = CGRect(x: 10, y: 300, width: 300, height: 0)
progress.backgroundColor = UIColor.whiteColor()
self.view.addSubview(progress)
// 定时器
NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "progressAction:", userInfo: progress, repeats: true)
}
func progressAction(timer: NSTimer) {
let progress = timer.userInfo as! UIProgressView
progress.progress += 0.05
if progress.progress == 1 {
// timer.invalidate() // 关闭定时器
progress.progress = 0 // 进度条设置为0
}
}
Swift 菊花、UIPageControl和UIProgressView的更多相关文章
- Swift - 进度条(UIProgressView)的用法
1,创建进度条 1 2 3 4 var progressView=UIProgressView(progressViewStyle:UIProgressViewStyle.Default) progr ...
- swift系统学习控件篇:UIProgressView+NSTimer+UIstepper+UIAlertController
工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIProgressView+NSTimer+UIstepper UIStepper UIP ...
- UIProgressView swift
// // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...
- Swift - 页控件(UIPageControl)的用法
使用页控件可以用来展示多个桌面.比如很多应用第一次登陆时,会在开始页面使用页控件来介绍功能,通过左右滑动来切换页. 通常我们使用UIPageControl和UIScrollView相互结合来实现多页切 ...
- iOS开发——UI篇Swift篇&UIProgressView
UIProgressView override func viewDidLoad() { super.viewDidLoad() titleLabel.text = titleString // Do ...
- swift 实践- 10 -- UIProgressView
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa ...
- swift开发之 -- 自动轮播图(UIScrollView+UIPageControl+Timer)
比较简单,原理就不说了,这里只做记录: 代码如下: 1,准备 var pageControl:UIPageControl? var myscrollView:UIScrollView? var myT ...
- swift - UIProgressView的用法
1.创建进度条 progressView.frame = CGRect(x:10, y:230, width:self.view.bounds.size.width - 20, height:150) ...
- Swift学习之熟悉控件
最近是比较清闲一些的,对于一个开发者来说,这也是一个很好的充电机会.以前做项目都是使用Objective-C去开发,但我们都知道,Swift语言从2014年的出现到现在,一步一步变的完善,渐渐变的受欢 ...
随机推荐
- 制作 macOS High Sierra U盘USB启动安装盘方法教程 (全新安装 Mac 系统)
方法一:使用命令行创建制作 macOS High Sierra 正式版 USB 安装盘 首先,准备一个 8GB 或更大容量的 U盘,并备份好里面的所有资料. 下载好 macOS High Sierra ...
- angularjs 整合bootstrap 时间控件
一.引入js <link href="${basePath}/static/plugin/bootstrap/css/bootstrap-datetimepicker.min.css& ...
- 【bzoj2333 & luoguP3273】棘手的操作(线段树合并)
题目传送门:bzoj2333 luoguP3273 这操作还真“棘手”..听说这题是可并堆题?然而我不会可并堆.于是我就写了线段数合并,然后调了一晚上,数据结构毁一生!!!QAQ…… 其实这题也可以把 ...
- C#实现日历样式的下拉式计算器
C#实现日历样式的下拉式计算器 原文地址:http://developer.51cto.com/art/201508/487486.htm 如果我们正在做一个类似于库存控制和计费系统的项目,有些部分可 ...
- 2017 ACM/ICPC Asia 南宁区 L The Heaviest Non-decreasing Subsequence Problem
2017-09-24 20:15:22 writer:pprp 题目链接:https://nanti.jisuanke.com/t/17319 题意:给你一串数,给你一个处理方法,确定出这串数的权值, ...
- 新一代调试王者Console
随着JS在Web前端中能做的事情越来越多,责任越来越大,而地位也越来越重要.传统的alert调试方式已经渐渐不能满足前端开发的种种场景.而且alert调试方式弹出的调试信息,那个窗口着实不太美观,而且 ...
- 关于java 线程池 ThreadPoolExceutor 之 TestDemo
public class App { public static void main(String[] args) throws InterruptedException { System.out.p ...
- git tags 管理
新建标签: git tag -a V1.1 -m "some thing" (新建标签前请先commit代码) 推送标签: git push --tags (推送标签前请先推送代码 ...
- 基础系列(1)之干掉JavaScript变量作用域
今天去某顺公司面试,发现一些基础知识都不记得了,于是乎决定把js基础系列的全部梳理一遍,今天就整理下js变量作用域的相关基础知识点,配合最常遇到的笔试题阐述. 题一: var g = "a ...
- 初学Selenium遇到的那些坑
一.遇到一个下拉选择框,可以点击继续选择: 所以click两次就可以了: 二.国际话问题 bdId.selectByIndex(index);//index位下拉框内容的下标,从0开始, 数组形式[ ...