zoukankan      html  css  js  c++  java
  • page enable,

    -(IBAction)doImage:(id)sender

    {

        CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;

        NSArray *mArray = @[@"1.jpeg",@"2.jpeg",@"3.jpeg",@"4.jpeg"];

        for (int i = 0; i<mArray.count; i++) {

            NSString *imageName = [mArray objectAtIndex:i];

            UIImage *ig = [UIImage imageNamed:imageName];

            UIImageView *mImageView = [[UIImageView alloc]initWithImage:ig];

            mImageView.frame = CGRectMake(i*screenWidth, 0, screenWidth, 400);

            [self.mScrollview addSubview:mImageView];

        }

        self.mScrollview.contentSize = CGSizeMake(mArray.count*screenWidth, 400);

        self.mScrollview.frame = CGRectMake(0, 0, screenWidth, 400);

        self.mScrollview.delegate = self;

        self.mScrollview.pagingEnabled = YES;

        self.mPageControl.currentPage = 0;

        self.mPageControl.numberOfPages = mArray.count;

        [self.mPageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];

        

    }

     

     

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView

    {

        CGFloat pageWidth = scrollView.frame.size.width;

        int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;

        self.mPageControl.currentPage = page;

        

    }

     

    - (void)changePage:(id)sender

    {

        int page = self.mPageControl.currentPage;

        CGRect frame = self.mScrollview.frame;

        frame.origin.x = frame.size.width * page;

        frame.origin.y = 0;

        [self.mScrollview scrollRectToVisible:frame animated:YES];

    }

  • 相关阅读:
    centOS7 查看防火墙状态 开放端口
    PHP之Trait详解 转
    ps 树形显示
    composer 打印美化
    第一章 Java Web应用开发技术
    团队博客20
    团队博客19
    团队博客18
    团队博客17
    团队博客16
  • 原文地址:https://www.cnblogs.com/guligei/p/4419486.html
Copyright © 2011-2022 走看看