当前位置: 首页 > news >正文

郑州可以做网站的公司北京网站排名制作

郑州可以做网站的公司,北京网站排名制作,织梦网站地图制作教程,中国电商平台排行榜前100简介 在现在的一些App中常常见到图片轮播器#xff0c;一般用于展示广告、新闻等数据#xff0c;在iOS内并没有现成的控件直接实现这种功能#xff0c;但是通过UIScrollView的允许分页设置#xff0c;可以实现滚动轮播的功能。 轮播原理 UIScrollView对象有pagingEnable成员…简介 在现在的一些App中常常见到图片轮播器一般用于展示广告、新闻等数据在iOS内并没有现成的控件直接实现这种功能但是通过UIScrollView的允许分页设置可以实现滚动轮播的功能。 轮播原理 UIScrollView对象有pagingEnable成员如果设置为YES那么每一个scrollView尺寸这么大的区域就会被当作一页在滚动时会根据滚动的比例自动计算应该切换到哪一页。 无限滚动原理 要实现无限滚动需要额外的两张图片假设我们的图片有五张存在images数组中那么我们在将图片插入到scrollView中时在第一张图片前面插入一个最后一张图片作为辅助图片在最后一张后面插入一个第一张图片作为辅助图片。这样当滚动到第一张前面一张时在页面切换结束后无动画的切换scrollView的偏移量为最后一张图片不包含最后一张后面的第一张那个辅助图片这样就实现了由辅助图片到真实图片的过渡之所以设置辅助图片是为了在滚动中看到那个真实图片。同理当滚动到最后一张的后面一张时我们吧scrollView的偏移量设置为第一张图片即可。 具体的代码实现 这个代码是在开发一个项目中所写的已经封装称一个View只需要调用initWithFrame指定轮播器尺寸然后通过设置images成员的值即可实现无限滚动的轮播。 // .h // // ESPicPageView.h // 享技 // // Created by 11 on 11/30/15. // Copyright © 2015 soulghost. All rights reserved. // #import UIKit/UIKit.h interface ESPicPageView : UIView property (nonatomic, strong) NSArray *images; end // -------------------------------------------- // .m // // ESPicPageView.m // 享技 // // Created by 11 on 11/30/15. // Copyright © 2015 soulghost. All rights reserved. // #import ESPicPageView.h #import UIImageViewWebCache.h interface ESPicPageView () UIScrollViewDelegate property (nonatomic, weak) UIScrollView *scrollView; property (nonatomic, weak) UIPageControl *pageControl; property (nonatomic, assign) CGFloat imgW; property (nonatomic, assign) CGFloat imgH; property (nonatomic, strong) NSTimer *timer; property (nonatomic, strong) NSArray *imageViews; property (nonatomic, assign) NSInteger imageCount; end implementation ESPicPageView - (instancetype)initWithFrame:(CGRect)frame{ if (self [super initWithFrame:frame]) { self.backgroundColor [UIColor blueColor]; UIScrollView *scrollView [[UIScrollView alloc] init]; self.scrollView scrollView; self.scrollView.delegate self; self.scrollView.pagingEnabled YES; self.scrollView.showsHorizontalScrollIndicator NO; self.scrollView.backgroundColor [UIColor whiteColor]; [self addSubview:scrollView]; self.imgW frame.size.width; self.imgH frame.size.height; [self setNeedsLayout]; UIPageControl *pageControl [[UIPageControl alloc] initWithFrame:CGRectMake(frame.size.width - 50, frame.size.height - 10, 0, 0)]; self.pageControl pageControl; self.pageControl.numberOfPages 1; [self addSubview:pageControl]; self.timer [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:selector(nextImage) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; } return self; } - (void)nextImage{ NSInteger page self.pageControl.currentPage; page self.pageControl.currentPage 1; CGPoint offset CGPointMake((1 page) * self.imgW, 0); [self.scrollView setContentOffset:offset animated:YES]; } - (void)setupImageViews{ for (int i 0; i self.images.count 2; i) { UIImageView *imageView [[UIImageView alloc] init]; CGFloat imageX i * self.imgW; CGFloat imageY 0; CGFloat imageW self.imgW; CGFloat imageH self.imgH; imageView.frame CGRectMake(imageX, imageY, imageW,imageH); [self.scrollView insertSubview:imageView atIndex:0]; } } - (NSArray *)imageViews{ if (_imageViews nil) { NSMutableArray *arr [NSMutableArray array]; for (int i 0; i self.images.count 2; i) { UIImageView *imageView [[UIImageView alloc] init]; CGFloat imageX i * self.imgW; CGFloat imageY 0; CGFloat imageW self.imgW; CGFloat imageH self.imgH; imageView.frame CGRectMake(imageX, imageY, imageW,imageH); [self.scrollView insertSubview:imageView atIndex:0]; [arr addObject:imageView]; } _imageViews arr; } return _imageViews; } - (void)setImages:(NSArray *)images{ _images images; self.imageCount images.count; self.pageControl.numberOfPages self.imageCount; [self addPics]; } - (void)addPics{ for (int i 0; i self.images.count 2; i) { UIImageView *imageView self.imageViews[i]; if (i 0) { imageView.image [self.images lastObject]; }else if(i self.images.count 1){ imageView.image [self.images firstObject]; }else{ imageView.image self.images[i - 1]; } } } - (void)layoutSubviews{ [super layoutSubviews]; 转载于:https://www.cnblogs.com/jx66/p/6268533.html
http://www.sadfv.cn/news/60102/

相关文章:

  • 彩票网站做代理网站建设去哪
  • 网站seo优化有哪些方面做网站的时候用的什么框架
  • 广东seo网站优化公司封面上的网站怎么做的
  • dw网站怎么做跳转免费网页在线代理服务器
  • 山南网站建设广州做网站 汉狮网络
  • 珠宝类网站模板服务器 多wordpress
  • wordpress js 插件开发东莞网站建设分享seo
  • 智能建网站用什么网站做pathway分析
  • 重庆市做网站的公司有哪些网站建设服务代理商
  • 企业手机网站建设行情seo关键字怎么优化
  • 网站备案时 首页网站域名可以做端口映射吗
  • 网站首页制作的过程可以建网站的公司
  • 餐馆网站模板淘宝联盟的网站怎么做
  • 网站流量如何提高沈阳网页设计培训
  • 广东省网站集约化建设方案哪些网站做任务可以赚钱
  • 义乌网图科技有限公司怎么样网站优化怎样做
  • 如何查询网站快照河北网站建设工程
  • 网站开发 图标微信app下载安装官方版2022网址
  • 国内公司网站需要备案吗网页制作公司北京
  • 网站主服务器所在地地址企业年金退休后如何领取
  • 国外儿童社区网站模板企业网站seo多少钱
  • 企业网站建设费用入什么科目绥化市新闻最新消息
  • 网站建设百度知道虾米WordPress
  • 企业宣传册免费模板网站网站设计 方案
  • 专业网站是指什么深圳防疫最新政策
  • 企业做网站需要的资料上海模板网站套餐
  • 麻涌企业网站建设dw网站的站点建设
  • 兰州建设网站食药监局网站建设方案
  • 北京开发办网站wordpress链接微博
  • 网站建设公司的市场定位中国网站备案