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张图片的轮播,我借鉴了几个博文,得到两种方法实现: [第一种]:如下图(图片来源于 ...
随机推荐
- bzoj 1798: [Ahoi2009]Seq 维护序列seq 线段树 区间乘法区间加法 区间求和
1798: [Ahoi2009]Seq 维护序列seq Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeO ...
- jProfiler远程连接Linux监控jvm的运行状态
第一步:下载软件官网地址:https://www.ej-technologies.com/download/jprofiler/files,下载一个linux服务端,一个windows客户端 GUI界 ...
- PowerDesigner设置唯一约束/唯一索引/唯一键
注意:还需要设置unique约束,也是在这个界面. 参考: https://blog.csdn.net/cnham/article/details/6676650 https://blog.csdn. ...
- The YubiKey -- HOW IT WORKS
A single YubiKey has multiple functions for protecting access to your email, your apps and your phys ...
- [Node.js]Path模块
摘要 path模块提供了一些处理文件路径问题的工具. path模块 引入模块 var path=require("path"); 方法 1 path.normalize(p)规范化 ...
- C#子类如何调用父类
C#中子类是如何调用父类的?带着这个问题,体验如下: □ 通过子类无参构造函数创建子类实例 创建父类Person和子类Student. public class Person { public Per ...
- Oracle数据库--解决单张表中数据量巨大(大数据、数据量上百万级别,后查询,更新数据等耗时剧增)
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/QQ578473688/article/details/54561397 思路1:采用备份表 备份表中 ...
- .NET:CLR via C# The Interlocked Anything Pattern
Many people look at the Interlocked methods and wonder why Microsoft doesn't create a richer set of ...
- 前端新手如何安装webstorm ,初步搭建react项目
下载安装webstorm:配置成功: 配置成功后就可以开启webstorm项目了.(存微信收藏..) 1:在webstorm下配置node环境: 2:完成之后: React官方脚手架地址: https ...
- Mongodb安全认证及Java调用
Mongodb安全认证在单实例和副本集两种情况下不太一样,单实例相对简单,只要在启动时加上 --auth参数即可,但副本集则需要keyfile. 一.单实例 1.启动服务(先不要加auth参数) 2. ...