美文网首页
ios 轮播图

ios 轮播图

作者: 繁华落尽终是殇 | 来源:发表于2017-08-09 16:17 被阅读0次

#import "ViewController.h"

#import "oneViewController.h"

@interface ViewController (){

UIScrollView *theSceo;

NSArray *theArr;

UIPageControl *thePage;

}

@end

@implementation ViewController

- (void)viewDidLoad {

            [super viewDidLoad];

            self.view.backgroundColor = [UIColor whiteColor];

            //初始化滚动视图

       theSceo = [[UIScrollView alloc]initWithFrame:self.view.frame];

        //设置代理

     theSceo.delegate = self;

      //设置按页滚动

    theSceo.pagingEnabled = YES;

    //设置是否显示滚动条

    theSceo.showsHorizontalScrollIndicator = NO;

    //添加到视图

[self.view addSubview:theSceo];

theArr = @[@"1.jpeg",@"2.jpeg",@"3.jpeg",@"4.jpeg"];

CGFloat x = 0.0

theSceo.contentSize = CGSizeMake(x, self.view.frame.size.height);

//初始化一个分页控制器

thePage = [[UIPageControl alloc]initWithFrame:CGRectMake((self.view.frame.size.width)/2-30, self.view.frame.size.height/5*4, 60, 20)];

//设置分页控制器个数

thePage.numberOfPages = theArr.count;

//设置分页控制器的 颜色

thePage.pageIndicatorTintColor = [UIColor whiteColor];

//社会化做分页控制器选中的颜色

thePage.currentPageIndicatorTintColor = [UIColor redColor];

//添加到视图

[self.view addSubview:thePage];

}

//实现分页控制器与滚动视图的关联

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

thePage.currentPage = theSceo.contentOffset.x/self.view.frame.size.width;

}

-(void)tz{

oneViewController *v1 = [oneViewController new];

[self presentViewController:v1 animated:YES completion:^{

}];

}

@end

相关文章

  • 轮播大法——SDCycleScrollView 源码思路解析

    SDCycleScrollView 轮播图源码解析 一、开篇 轮播图控件,在 iOS 应用上是有很多应用的。 这个...

  • iOS使用UIScrollView实现无限循环轮播图

    何为轮播图?在 iOS中其实就是利用UIScrollView来展示超出屏幕范围的图片或者是其它内容。轮播图又分为手...

  • iOS 轮播图

    轮播图几乎是每一个 App 都会有的功能,而在 UIKit 中又找不到能够直接实现轮播图的视图控件。因此我们需要通...

  • ios 轮播图

    好的第三方 http://www.code4app.com/thread-14507-1-1.html

  • ios 轮播图

    #import "ViewController.h" #import "oneViewController.h" ...

  • iOS轮播图

    用collectionView自定义实现一个无限滚动的轮播图 这里主要说一下无限轮播的核心思路和解决方案 我先以s...

  • iOS 轮播图

  • IOS 轮播图

    轮播图有很多种方式创建,其中利用collectionView是最为简单的一种,以下为这种方式的思路代码。 初始化c...

  • iOS 轮播图

    轮播图是App中常用的展示界面,主要用到的控件有UIScrollView和UIPageControl。难点有两处,...

  • iOS 轮播图

    大神连接 BannerCell BannerView 实现

网友评论

      本文标题:ios 轮播图

      本文链接:https://www.haomeiwen.com/subject/emlqrxtx.html