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变了,这是母版页导致的.因为母版页怕母版页本身页面中的控件 ...
随机推荐
- SpringBoot应用篇(二):SpringSecurity实现带验证码的登录认证 附代码
一.文章简介 本文简要介绍了spring security的基本原理和实现,并基于springboot整合了spring security实现了基于数据库管理的用户的登录和登出,登录过程实现了验证码的 ...
- VUE+Element UI实现简单的表格行内编辑效果
原理是通过Css控制绑定的输入控件与显示值,在选中行样式下对控件进行隐藏或显示 <!DOCTYPE html> <html> <head> <meta cha ...
- weed3-2.2.细讲插入和更新
Weed3 一个微型ORM框架(只有0.1Mb哦) 源码:https://github.com/noear/weed3 源码:https://gitee.com/noear/weed3 这篇重点讲讲插 ...
- C# 32位程序 申请大内存
后期生成事件命令行代码: cd /d $(DevEnvDir)cd..cd..cd VC\bineditbin /largeaddressaware $(TargetPath)
- 在 ASP.NET Core 中启用跨域请求(CORS)
本文介绍如何在 ASP.NET Core 的应用程序中启用 CORS. 浏览器安全可以防止网页向其他域发送请求,而不是为网页提供服务. 此限制称为相同源策略. 同一源策略可防止恶意站点读取另一个站点中 ...
- autojump 之 git本地安装
1.克隆autojump的repo,Terminal下执行: git clone git://github.com/joelthelion/autojump.git 然后进入c ...
- GO基础之异常处理
一.异常 1. 错误指程序中出现不正常的情况,从而导致程序无法正常执行.•大多语言中使用try... catch... finally语句执行.假设我们正在尝试打开一个文件,文件系统中不存在这个文件. ...
- Jsf中进度条的用法
Jsf中进度条的用法 前端页面 <!-- 进度条 --> <p:progressBar widgetVar="pbAjax" ajax="true&qu ...
- Effect:Mobile ocd
Satisfy the following two Keep your phone at all times Check your phone even if there's no news Alwa ...
- WebSessionStore: Could not obtain reference to HttpContext
IBatis.net在多线程中报错“WebSessionStore: Could not obtain reference to HttpContext” 分析: 因为ibatis的ISqlMapSe ...