UIScrollView 图片循环滚动
1:假如有6个图片:那个,Scrollview的大小加 7 个图片的大小
2:
//ImageScrollView;
UIScrollView *imageScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(, , , )];
imageScroll.bounces = YES;
imageScroll.pagingEnabled = YES;
imageScroll.userInteractionEnabled = YES;
imageScroll.showsVerticalScrollIndicator = NO;
imageScroll.showsHorizontalScrollIndicator = NO;
imageScroll.delegate = self;
imageScroll.contentSize = CGSizeMake( * , );
[theScrollView addSubview:imageScroll];
[imageScroll release]; //加上图片;
for (int i = ; i < ; i++) {
UIImageView *aImageView = [[UIImageView alloc]initWithFrame:kCR( + *i, , , )];
aImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"keenLC%d.jpg",i+]];
if (i==) {
aImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"keenLC%d.jpg",]];
} [imageScroll addSubview:aImageView];
[aImageView release]; }
//图片数字label
imageNumLabel = [[UILabel alloc]initWithFrame:kCR(, imageScroll.bottom - , , )];
imageNumLabel.text = @"1/6";
imageNumLabel.textAlignment = NSTextAlignmentCenter;
imageNumLabel.textColor = [UIColor whiteColor];
imageNumLabel.backgroundColor = [UIColor clearColor];
[theScrollView addSubview:imageNumLabel];
[imageNumLabel release];
3: ScrollView的代理
#pragma mark Scroll delegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;{
int currentPage = floor((scrollView.contentOffset.x - scrollView.frame.size.width / ) / scrollView.frame.size.width) + ;
imageNumLabel.text = [NSString stringWithFormat:@"%d/6",currentPage + ];
//imageScroll.transform = CGAffineTransformMakeScale(1,1);
if (currentPage==) {
[scrollView setContentOffset:CGPointMake(, ) animated:NO];
imageNumLabel.text = [NSString stringWithFormat:@"%d/6",];
}
}
UIScrollView 图片循环滚动的更多相关文章
- 使用UIScrollView 结合 UIImageView 实现图片循环滚动
场景: 在开发工作中,有时我们需要实现一组图片循环滚动的情况.当我们使用 UIScrollView 结合 UIImageView 来实现时,一般 UIImageView 会尽量考虑重用,下面例子是以( ...
- cocos2d(背景图片循环滚动)
背景图片循环滚动 使用action 实现的: 主要有两个背景图片交替循环滚动:我选的两个背景图片的宽度都是1024的 ,所以定义了#define BGIMG_WIDTH 1024 代码如下: 在Hel ...
- 基于html5可拖拽图片循环滚动切换
分享一款基于html5可拖拽图片循环滚动切换.这是一款支持手机端拖拽切换的网站图片循环滚动特效.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div id="s ...
- 特殊例子--JavaScript代码实现图片循环滚动效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 图片循环滚动效果shader
背景无限循环滚动效果,有X和Y轴的速度控制,方便控制.见下图,操作步骤同之前的背景循环设置. shader如下: Shader "Custom/Scroll" { Properti ...
- UIScrollView现实循环滚动
#import "RootViewController.h" #define width [UIScreen mainScreen].bounds.size.width #defi ...
- iOS 图片循环滚动(切片效果)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIAp ...
- JS实现鼠标移上去图片停止滚动移开恢复滚动效果
这是在做个人站的时候展示项目成果,因为不光需要展示,还需要介绍详细内容,就在滚动展示的地方做了这个效果以便于点开想要看的项目. 首先,要做的是一个需要滚动的区域.我前边写过一个关于图片循环滚动的示例, ...
- UIScrollView循环滚动1
现在基本每一个商业APP都会有循环滚动视图,放一些轮播广告之类的,都是放在UIScrollView之上.假如我要实现N张图片的轮播,我借鉴了几个博文,得到两种方法实现: [第一种]:如下图(图片来源于 ...
随机推荐
- 安装gitlab管理自己的代码
安装gitlab的资料网上搜索很多,但发现很多都是比较老的资料了.我把我安装的过程记录一下,应该是最简单的过程了 1. 到 https://about.gitlab.com/downloads/ 下载 ...
- UVALive 5971
Problem J Permutation Counting Dexter considers a permutation of first N natural numbers good if it ...
- BZOJ 1192 鬼谷子的钱袋 数论
1192:鬼谷子的钱袋 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1926 Solved: 1417 题目连接 http://www.lydsy ...
- Codeforces Round #288 (Div. 2) C. Anya and Ghosts 模拟 贪心
C. Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- SpringMVC 方法参数设置
/** 在方法中配置参数: (1) 内置对象配置: request:获取cookie.请求头... 获取项目根路径 request.getContextPath() response:用于ajax的输 ...
- Android中播放本地SD卡中歌曲须要的加入的权限
使用MediaPlayer播放本地Mp3文件时.须要注意的訪问路径的问题以及訪问权限的问题. 1.訪问路径:/storage/emulated/0 此路径即为手机的根路径,能够通过下载ES文件浏览器软 ...
- 用最简单的例子理解复合模式(Composite Pattern)
在显示树形结构时,复合模式有很好的体现.本篇显示如下部门结构: 以上,有的节点包含子节点,有的节点部包含子节点.不管是什么节点,每个节点就代表一个部门. 首先设计一个关于部门的抽象基类. public ...
- 各种语言的注释总结--from wiki
Comments can be classified by: style (inline/block) parse rules (ignored/interpolated/stored in memo ...
- java实时监控mysql数据库变化
对于二次开发来说,很大一部分就找找文件和找数据库的变化情况 对于数据库变化.还没有发现比较好用的监控数据库变化监控软件. 今天,我就给大家介绍一个如何使用mysql自带的功能监控数据库变化 1.打开数 ...
- 偏执却管用的10条Java编程技巧
本文由 ImportNew - LynnShaw 翻译自 javacodegeeks.欢迎加入翻译小组.转载请见文末要求. 经过一段时间的编码(咦,我已经经历了将近20年的编程生涯,快乐的日子总是过得 ...