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

做网站单页视频电商品牌网站开发运营

做网站单页视频,电商品牌网站开发运营,聚名网域名注册,刷赞网站推广qq免费简介 在现在的一些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.zqtcl.cn/news/351527/

相关文章:

  • 本地宁波网站建设电子商务网站建设工具都有那些
  • 网站建设的基本目标免费 wordpress企业主题
  • 专业网站建设微信商城开发规划馆网站建设
  • 网站建设公司沈阳西安建设工程信息交易中心官网
  • 青海住房和城乡建设部网站wordpress php7.3
  • 网站后台重置密码怎么做360网站怎么做网址链接
  • 广告网站建设及推广网站建设怎样推广
  • 做网站使网页不居中滁州注册公司流程和费用
  • 做网站广告经营者个性定制网站
  • 网站开发 北京外包公司软件公司网站建设
  • 网络认证入口seo免费诊断
  • 十大知名博客网站郑州企业建站公司定制
  • 视频网站如何做引流网站首页 关键词
  • 建设机械网站精英大港做网站
  • 潜山网站建设公司哪里有wordpress相册投票插件
  • 网站建设制作过程网站添加支付功能
  • 网站制作字体即墨公司做网站
  • vue 做pc网站可以吗哪个网站买域名便宜
  • 做销售网站那家好金华住房与城乡建设部网站
  • apple私人免费网站怎么下载无锡网站建设技术
  • 移动应用网站开发阶段作业信息型网站有哪些
  • 监控直播网站开发网站建设与管理总结
  • 青岛城阳网站设计免费网站成品
  • 做服装外贸的网站ghost wordpress
  • 建设银行的网站为什么这么卡网页设计用啥软件
  • 电子商务 网站开发南阳网网站建设
  • 中小型企业网络拓扑图及配置株洲seo网站推广
  • 中国镇江网站如何搭建自己的网址
  • wordpress 自动广告seo搜索引擎优化原理
  • 区块链网站用vue.js做怎么样长春站建筑