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

两学一做专题网站wordpress微信订阅号

两学一做专题网站,wordpress微信订阅号,在中国如何申请域名,重庆电商网站建设费用轮播图为一种常见的方式#xff0c;常用于各种网站#xff0c;或者App中#xff0c;当然#xff0c;作为APP的启动视图也是不错的选择。 闲时封装了一个#xff0c;仅供新手参考。 1.新建工程#xff0c;建立轮播图类 建立一个空的工程#xff0c;新建一个类#xff0c…轮播图为一种常见的方式常用于各种网站或者App中当然作为APP的启动视图也是不错的选择。 闲时封装了一个仅供新手参考。 1.新建工程建立轮播图类 建立一个空的工程新建一个类起名为Carousel继承于UIView 2.编写Carousel类接口 1 interface Carousel : UIView2 typedef NS_ENUM(NSInteger,UICarouselPageType){3 //建立一个枚举型来设置Carousel的样式4 UICarouselPageTypeCenter,//设置pageControl在中心5 UICarouselPageTypeLeft, //设置pageControl在左侧6 UICarouselPageTypeRight, //设置pageControl在右侧7 };8 property(nonatomic,strong)NSArray *ImageArry;//用于接收来自外部的图片9 property(nonatomic,assign)NSTimeInterval duration;//用于接收每张图片的持续时间 10 property(nonatomic,assign)UICarouselPageType PageType; 11 end 3.内部代码 1.用懒加载的方式定义UIScrollView和UIPageControl   (1)为Carousel类建立延展   1 interface Carousel()UIScrollViewDelegate 2 property(nonatomic,strong)UIScrollView *scroll; 3 property(nonatomic,strong)UIPageControl *pageControl; 4 property(nonatomic,assign)int index; 5 property(nonatomic,strong)NSTimer *timer; 6 end      (2)重写初始化方法 1 -(instancetype)initWithFrame:(CGRect)frame{ 2 self [super initWithFrame:frame]; 3 if (self) { 4 _timer [[NSTimer alloc]init]; 5 _index0; 6 } 7 return self; 8 }   3scrollView 1 -(UIScrollView *)scroll{2 if (_scrollnil) {3 _scroll [[UIScrollView alloc]initWithFrame:self.bounds];4 _scroll.delegateself;5 _scroll.contentSizeCGSizeMake([_ImageArry count]*WIDTH,HEIGHT);6 _scroll.pagingEnabledYES;//允许整页翻动7 _scroll.bouncesNO;8 _scroll.showsHorizontalScrollIndicatorNO;9 _scroll.showsVerticalScrollIndicatorNO; 10 for (int i0; i[_ImageArry count]; i) { 11 UIImageView *imageView [[UIImageView alloc]initWithFrame:CGRectMake(i*WIDTH, 0, WIDTH, HEIGHT)]; 12 UIImage *image[_ImageArry objectAtIndex:i]; 13 imageView.imageimage; 14 [_scroll addSubview:imageView]; 15 } 16 } 17 return _scroll; 18 }    (4)pageControl 1 -(UIPageControl *)pageControl{2 if (_pageControl nil) {3 _pageControl [[UIPageControl alloc]init];4 [self setPageControlFrame];5 _pageControl.numberOfPages[_ImageArry count];6 _pageControl.pageIndicatorTintColor[UIColor greenColor];7 _pageControl.currentPageIndicatorTintColor[UIColor redColor];8 [_pageControl addTarget:self action:selector(change:) forControlEvents:UIControlEventValueChanged];9 } 10 return _pageControl; 11 } 12 -(void)setPageControlFrame{ 13 //当PageType有不同值的时候 有不同的frame 14 if (_PageTypeUICarouselPageTypeLeft) { 15 _pageControl.frameCGRectMake(0,HEIGHT-20,150,20); 16 }else if (_PageType UICarouselPageTypeRight){ 17 _pageControl.frameCGRectMake(WIDTH-150,HEIGHT-20,150,20); 18 }else{ 19 _pageControl.frameCGRectMake(WIDTH/2-75,HEIGHT-20,150,20); 20 } 21 } 22 -(void)change:(UIPageControl *)page{ 23 [_timer invalidate]; 24 _timernil; 25 _scroll.contentOffsetCGPointMake(page.currentPage*WIDTH, 0); 26 _index(int)page.currentPage;//重新给index赋值 27 _timer [NSTimer scheduledTimerWithTimeInterval:_duration target:self selector:selector(lunbo) userInfo:nil repeats:YES]; 28 }     (5) 重写ImageArray的set方法 1 -(void)setImageArry:(NSArray *)ImageArry{ 2 //重写Set方法 当ImageArray有值的时候显示scrollView和PageControl 3 if (_ImageArry!ImageArry) { 4 _ImageArry ImageArry; 5 [self addSubview:self.scroll]; 6 [self addSubview:self.pageControl]; 7 _timer [NSTimer scheduledTimerWithTimeInterval:_duration target:self selector:selector(lunbo) userInfo:nil repeats:YES]; 8 } 9 }   (6)Scroll的代理方法 1 -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{2 //开始拖动时销毁计时器3 [_timer invalidate];4 _timer nil;5 }6 -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{7 //减速结束时重新生成计时器8 _index(int)_pageControl.currentPage;//重新给index赋值9 _timer [NSTimer scheduledTimerWithTimeInterval:_duration target:self selector:selector(lunbo) userInfo:nil repeats:YES]; 10 } 11 -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ 12 _pageControl.currentPagescrollView.contentOffset.x/WIDTH; 13 }  4.应用Carousel类 1 #import ViewController.h2 #import Carousel.h3 interface ViewController ()4 end5 implementation ViewController6 7 - (void)viewDidLoad {8 [super viewDidLoad];9 Carousel *lunbo [[Carousel alloc]initWithFrame:CGRectMake(0, 100, 414, 300)]; 10 NSMutableArray *arr[[NSMutableArray alloc]initWithCapacity:9]; 11 for (int index1; index10; index) { 12 UIImage *image [UIImage imageNamed:[NSString stringWithFormat:%d.jpg,index]]; 13 [arr addObject:image]; 14 } 15 lunbo.duration1; 16 lunbo.PageTypeUICarouselPageTypeCenter; 17 lunbo.ImageArryarr; 18 [self.view addSubview:lunbo]; 19 // Do any additional setup after loading the view, typically from a nib. 20 }   效果图    转载于:https://www.cnblogs.com/pangxuhui/p/5671957.html
http://www.sadfv.cn/news/388866/

相关文章:

  • 网站开发需要哪些技能小说网站快速做排名
  • ps制作网站首页教程青岛做网站方案
  • 建站公司现状高端开发网站哪家专业
  • 网站变灰是什么事企业网站建设培训
  • 桂林建设网站公司php网站架设教程
  • 顺德水利和国土建设局网站wordpress 会员管理插件
  • 做设计必知网站亚马逊网站类型
  • 外贸电子网站建设企业网站建设多少家
  • 郑州网站建设专家贵州省交通工程建设质监局网站
  • 济南济阳网站建设微信朋友圈广告投放代理
  • 网站建设内容论文网站设计项目总结
  • 公司自己做网站抖音推广计划
  • 用花生壳做映射的网站需要备案dplayer wordpress
  • 女装商城网站建设wordpress怎么设计
  • 创建网站做搞笑视频免费空间说说赞
  • 在门户网站上爆光怎么做摇钱树手机论坛网站
  • 企业网站的在线推广方法有哪些青岛网站建设在哪
  • 佛山市外贸网站建设保世基官方网站建设
  • 怎么做网站推广韩国化妆品网站金色flash片头
  • python和php哪个做网站网站左侧导航栏设计
  • 怎么做自己的设计网站产品软文范例100字
  • 无极在线最新招聘兼职广州网站运营专业乐云seo
  • 电子商务网站建设优势网页链接转二维码
  • 江苏省建设通官方网站wordpress 固定 拼音网址
  • 网站开发流程图微商城开店
  • 新网站建设怎么样个人网站设计与制作源代码
  • 企业网站用视频做首页网站开发页面适应高度
  • 商城app网站开发淮安汽车集团网站建设
  • wordpress网站访问慢做软件用什么编程语言
  • 百度为什么会k网站wordpress menu背景