- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
int width=frame.size.width;
int height=frame.size.height;
scrollview=[[UIScrollView alloc] initWithFrame:CGRectMake(, , width, height)];
[self addSubview:scrollview];
for (int i=; i<; i++) {
UIImageView *imageview=[[UIImageView alloc] initWithFrame:CGRectMake(i*width, , width, height)];
imageview.image=[UIImage imageNamed:[NSString stringWithFormat:@"image%zi@2x.jpg",(i+)]];
[scrollview addSubview:imageview];
}
scrollview.contentSize=CGSizeMake(*width, height);
scrollview.pagingEnabled=YES;
scrollview.showsVerticalScrollIndicator=NO;
scrollview.showsHorizontalScrollIndicator=NO;
scrollview.delegate=self;
scrollview.bounces=NO; pagecontroller=[[UIPageControl alloc] initWithFrame:CGRectMake((width-)*0.5f, height--, , )];
[self addSubview:pagecontroller]; pagecontroller.currentPage=;
pagecontroller.numberOfPages=;
currentPage=; self.timer=[NSTimer scheduledTimerWithTimeInterval: target:self
selector:@selector(timer:) userInfo:nil repeats:YES];
[self.timer fire]; }
return self;
} -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
CGFloat width=self.bounds.size.width;
CGPoint point=scrollview.contentOffset;
CGFloat offenx=point.x;
pagecontroller.currentPage=offenx/width;
} -(void)timer:(NSTimer *)time{
if (currentPage>) {
currentPage=;
}
CGFloat width=self.bounds.size.width;
[UIView beginAnimations:nil context:nil];
scrollview.contentOffset=CGPointMake(currentPage*width, );
pagecontroller.currentPage=currentPage;
[UIView commitAnimations];
currentPage++;
}

最新文章

  1. 精通Web Analytics 2.0 (7) 第五章:荣耀之钥:度量成功
  2. ExtJs 学习之开篇(三)Ext.grid.Panel表格中的处理
  3. CentOS6.5菜鸟之旅:VIM插件NERDtree初探
  4. lua 的 WriteFile 和 ReadFile
  5. 函数 stat() 详解
  6. MVC中的Ajax(AjaxHelper)
  7. php 防止SQL注入函数
  8. 利用sql 存储过程把表中内容自动生成insert语句
  9. git(创建,提交,回退)
  10. lua table表
  11. nodejs模块引用
  12. PHP+XML写注册登录
  13. redis复习
  14. hdu 4643 GSM 计算几何 - 点线关系
  15. Linux-C语言标准输入输出
  16. Spark源码分析之Checkpoint的过程
  17. 20155217 实验四《Java面向对象程序设计》实验报告
  18. Spring MapFactoryBean例子
  19. Solidworks to Urdf to Sdf
  20. session和cookie基本操作

热门文章

  1. DevExpress ChartControl控件实现图表【转】
  2. 原生JS实现new方法、new一个对象发生的四部、new里面常用的优先级
  3. (转) Unity3D 使用Texturepacker打包工具制作NGUI(Atlas)图集
  4. nod32的内网在线更新设置
  5. idea中的maven模块变成灰色的可能原因
  6. windows命令行的使用,去掉&quot;半&quot;字
  7. mysql 表分区 查看表分区 修改表分区
  8. iOS 真机上图标不显示
  9. 微软BI 之SSAS 系列 - 实现Cube 以及角色扮演维度,度量值格式化和计算成员的创建
  10. 使用Json.Net解决MVC中各种json操作