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张图片的轮播,我借鉴了几个博文,得到两种方法实现: [第一种]:如下图(图片来源于 ...
随机推荐
- javascript中Date对象复习
js的Date对象不怎么经常用,所以忘得差不多,复习一下 1.声明一个Date对象,默认本地当前时间 var date = new Date();//Fri Apr 28 2017 14:26:19 ...
- Python threads synchronization: Locks, RLocks, Semaphores, Conditions, Events and Queues(Forwarding)
This article describes the Python threading synchronization mechanisms in details. We are going to s ...
- Content portal for Pocketables Tasker articles
http://www.pocketables.com/2013/03/overview-of-pocketables-tasker-articles.html I write a lot about ...
- Android实现两次按下返回键退出
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BAC ...
- Setup Factory打包winform程序
摘要 Setup Factory是一款软件安装工具.Setup Factory支持创建一个安装文件或一个单间的setup.exe文件,生成文件可以运行于任意版本的windows中. 步骤 1.安装Se ...
- Oracle中空值与数字相加问题
select 10 + 10 + 10 from dual 结果是30,全然没问题. select null + 10 + 10 from dual 结果是空串,但期望的结果是20. select n ...
- org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryRAYPKeHKTYSNdzc1;charset=UTF-8' not supported
原文:https://www.cnblogs.com/yueli/p/7552888.html 最近同事在做一个图片上传功能.在入参 body 中同时传入文件和其它基本信息结果出现如题异常.在此记录下 ...
- DockManager 如何快速隐藏DockPanel z
DockPanel在点击hide按钮时候如果鼠标不离开的话,panel还是没隐藏,某种情况下这种现象着实让人不爽,而且当鼠标离开后默认是很缓慢的隐藏 AutoHideSpeed不设置也可以,主要设置H ...
- IOS学习之基于IOS7的tab bar
转载请注明出处 http://blog.csdn.net/pony_maggie/article/details/28129473 作者:小马 什么是tabbar? 先几张图: 上图中蓝色框 ...
- win7下安装配置ftp服务器
1. win7操作系统自带了ftp组件,所以不需要另外下载.只需要在控制面板中,添加或删除组件中启用即可. 2. 在管理上,ftp和iis是属于同一个目录的.ftp也可以算是internet info ...