UIPageControl页面控制的控件
#import "ViewController.h"
#import "LazyScrollView.h"
@interface ViewController ()<UIScrollViewDelegate>
{
UIPageControl *pageControl;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scroView = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
scroView.contentSize = CGSizeMake(CGRectGetWidth([UIScreen mainScreen] .bounds)*10, 0);
scroView.delegate = self;// ?
[self.view addSubview:scroView];
CGFloat width = CGRectGetWidth([UIScreen mainScreen].bounds);
for (int i=0; i<10; i++) {
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(width*i, 0, width, CGRectGetHeight([UIScreen mainScreen].bounds))];
view.backgroundColor = [UIColor purpleColor];
view.layer.borderWidth = 4;// ?
view.alpha = 0.7;
view.layer.borderColor = [UIColor whiteColor].CGColor;
[scroView addSubview:view];
}
// UIPageControl页面控制的控件
/*
可以通过UIPageControl 来确定 当前视图在哪一页
1、一共有多少页 numberOfPages
2、当前页面 currentPage

UIPageControl ->.....
*/
pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, 300, CGRectGetWidth([UIScreen mainScreen].bounds), 30)];
//总共有多少页
pageControl.numberOfPages = 10;
//默认的当前页面
pageControl.currentPage = 0;
//设置页面控制的轨道颜色
pageControl.pageIndicatorTintColor = [UIColor brownColor];
//设置当前页面 点 的颜色
pageControl.currentPageIndicatorTintColor = [UIColor lightGrayColor];
//当一个页面的时候隐藏点点点
pageControl.hidesForSinglePage = YES;
[self.view addSubview:pageControl];
//如果默认页面 不是第一个页面 可以通过contentOffset 去设置偏移到哪一个位置
scroView.contentOffset = CGPointMake(CGRectGetWidth([UIScreen mainScreen].bounds)*pageControl.currentPage, 0);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSInteger curIndex = scrollView.contentOffset.x/CGRectGetWidth(scrollView.frame);
NSLog(@"%ld",curIndex);
pageControl.currentPage = curIndex;
}
UIPageControl页面控制的控件的更多相关文章
- WEB页面常用基本控件测试用例
一.树控件的测试外观操作 1)项目中的所有树是否风格一致 2)树结构的默认状态是怎样的.比如默认树是否是展开,是展开几级? 是否有默认的焦点? 默认值是什么?展开的节点图标和颜色? 2.执行操作 1 ...
- .net dataGridView当鼠标经过时当前行背景色变色;然后【给GridView增加单击行事件,并获取单击行的数据填充到页面中的控件中】
1.首先在前台dataGridview属性中增加onRowDataBound属性事件 2.然后在后台Observing_RowDataBound事件中增加代码 protected void Obser ...
- .NET同页面内用户控件与父页面以及控件之间方法调用
用户控件调用父页面的方法: //获得父页面 Page p =this.Parent.Page; Type pageType = p.GetType(); //父页面的方法名 MethodInfo mi ...
- Web页面上的控件
Web页面,即:.aspx文件页面的根目录下,分为了5部分 [0]-{System.Web.UI.LiteralControl} [1]-{System.Web.UI.HtmlControls.Htm ...
- .NET的三种缓存(页面缓存,控件缓存,自定义缓存)
BLL.Area bll = new BLL.Area(); protected void Page_Load(object sender, EventArgs e) { if (Cache[&quo ...
- .NET MVC 学习笔记(七)— 控制input控件
.NET MVC 学习笔记(七)— 控制input控件 画面中有时候需要输入数字,这时就需要控制input的输入.以下为保留两位有效数字. /* * 初始化数字输入 */ function initD ...
- Asp.net 恢复页面内用户控件内的控件ClientID
众所周知在Asp.net中如果一个页面添加了一个用户控件(或母版页),那么用户控件内的控件的 ClientID号会被自动添加页面中用户控件的ClientID 即页面中的控件内的控件ClientID ...
- [Asp.net]缓存之页面缓存,控件缓存,缓存依赖
写在前面 上篇文章介绍了缓存的基本概念及用途,另外也举了一个简单的例子,数据缓存(将一些耗费时间的数据加入到一个对象缓存集合中,以键值的方式存储.可以通过使用Cache.Insert()方法来设置缓存 ...
- 母版页改变被嵌套的页面中的控件ID的解决方法
使用过模板页的朋友都会很纳闷,怎么页面的用js通过getElementById(“id”):找不到对象.查看了页面源代码才发现,原来控件的ID变了,这是母版页导致的.因为母版页怕母版页本身页面中的控件 ...
随机推荐
- 使用Navicat Keygen激活(破解)Navicat Premium 12
1.到Navicat官网下载使用版本进行安装,具体操作不再详述.Navcat官网下载链接:http://www.navicat.com.cn/download/navicat-premium : 2. ...
- docker alphine 安装vim 等软件
alphine 不带 yum,所以只能用apt-get 安装 apt-get update apt-get install vim apt-get install net-tools
- nodejs环境使用Typeorm连接查询Oracle
首先是typeorm的官方地址, 国内有人翻了中文版,不保证时效性 ·通过npm安装下列包: typeorm //typeorm连接数据库 @types/node //类型系统 typescript ...
- FlowPortal 6.00c 使用xFormDesigner复制粘贴中文总是乱码
环境: Windows Server 2016中文版 FlowPortal 6.00C 问题: 使用xFormDesigner 在源码选项卡复制粘贴中文总是乱码. 解决办法: 控制面板---区域--- ...
- Auto入门 之 常用概念
1.SEMI (Semiconductor Equipment And Materials International) 国际半导体设备与材料产业协会 2.SECS SECS协议是基于RS-232或 ...
- 云K8S - AWS容器库ECR(ERS)编排ECS-EKS以及阿里云编排ACS-ACK
云K8S相关 AWS 部分-ECR(ERS) ECS EKS 20180824 Chenxin AWS的容器编排目前分为 ECS 和 EKS 两种. AWS价格说明 Fargate模式的ECS,换算成 ...
- JAVA工程师技能要求
近期做了个JAVA工程师分类, JAVA工程师可能是市场上最多类的程序员: 初级JAVA工程师的基本要求 Good basic programming skills 良好基本编程技能 Founda ...
- 从简单Sql探索优化之道
从简单Sql探索优化之道 梁敬彬 2016-03-17 09:39:41 本文需要优化的语句是select count(*) from t,这简单的统计语句一出,估计不少人纳闷了,能有啥优化空间,还优 ...
- PS各种行业文件创建
ps可以运用于:印刷.喷绘.网络等行业. 印刷 创建的印刷文件需要修改为毫米为单位,分辨率300以上,CMYK颜色格式: 16开的尺寸为:210*285mm:但在印刷之后,剪裁需要留出出血位,上下左右 ...
- Linux_更改时区和利用Crontab同步时间
一.更改时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 二.Crontab时间同步 crontab -e #crontab编辑 */5 ...