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变了,这是母版页导致的.因为母版页怕母版页本身页面中的控件 ...
随机推荐
- 1.Android-入门之系统架构介绍
1.Android 系统架构 android分为四个层,从高层到低层分别是应用程序层.应用程序框架层.系统运行库层和linux核心层,如下图所示: 2.application应用程序层 该层提供一些核 ...
- Scrcpy用电脑控制Android手机(支持Windows/macOS/Linux)
一.scrcpy简介 注意:拼写是scrcpy,非Python爬虫框架Scrapy. scrcpy可以通过adb调试的方式来将手机屏幕投到电脑上,并可以通过电脑控制您的Android设备.它可以通过U ...
- Linux-换yum源
1.打开centos的yum文件夹 cd /etc/yum.repos.d/ 2.用wget下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7. ...
- 精通awk系列(14):细说awk中的变量和变量赋值
回到: Linux系列文章 Shell系列文章 Awk系列文章 awk变量 awk的变量是动态变量,在使用时声明. 所以awk变量有3种状态: 未声明状态:称为untyped类型 引用过但未赋值状态: ...
- Unity Ruby's Adventure 第二步
加载游戏资源(已注册Unity) Step1:打开Unity 依次点击 Window>Asset Store(资源商店) Step2:搜索资源 Ruby's Adventure Step3:购买 ...
- Android 仿真器 无法启动排查
从命令行启动仿真器,可以查看其输出. Microsoft Windows [版本 10.0.18362.145] (c) 2019 Microsoft Corporation.保留所有权利. C:\U ...
- Cross-Site Scripting:DOM 跨站点脚本:DOM
- 洛谷P5364 [SNOI2017]礼物 题解
传送门 /* 热情好客的小猴子请森林中的朋友们吃饭,他的朋友被编号为 1∼N,每个到来的朋友都会带给他一些礼物:大香蕉.其中,第一个朋友会带给他 11 个大香蕉,之后,每一个朋友到来以后,都会带给他之 ...
- day 27-1 反射、内置方法
反射 反射:通过字符串来映射到对象的属性 class People(): def __init__(self, name, age): self.name = name self.age = age ...
- How to: Apply Attributes to Entity Properties when Using Model First 如何:在ModelFirst时将属性应用于实体属性
In a Model First data model, object properties are declared in the designer-generated files, and you ...