zoukankan      html  css  js  c++  java
  • 使用CATransition实现scrollView的多张页面滚动

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    UIImage *image = [UIImage imageNamed:@"1.jpg"];
    _imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    _imageView.image = image;
    [self.view addSubview:_imageView];
    //利用for循环创建UIImage,并且添加到数组中
    _imageList = [NSMutableArray arrayWithCapacity:8];
    for (int i = 1; i <= 8; i++) {
    NSString *imageName = [NSString stringWithFormat:@"%d.jpg",i];
    UIImage *image = [UIImage imageNamed:imageName];
    [_imageList addObject:image];
    }
    CGFloat w = 80;
    //添加pageController ---->此处的page没有做处理
    UIPageControl *page = [[UIPageControl alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - w) / 2, 416, w, 20)];
    page.numberOfPages = 8;
    [self.view addSubview:page];
    }

    #pragma mark 轻扫手势监听方法
    - (IBAction)swipe:(UISwipeGestureRecognizer *)sender
    {
    //转场动画
    CATransition *transition = [[CATransition alloc] init];
    transition.type = @"push";
    if (UISwipeGestureRecognizerDirectionLeft == sender.direction) {
    transition.subtype = kCATransitionFromLeft;
    _imageView.tag = (_imageView.tag + 1) % 8;
    }else if (UISwipeGestureRecognizerDirectionRight == sender.direction){
    transition.subtype = kCATransitionFromRight;
    _imageView.tag = (_imageView.tag - 1 + 8) % 8;
    }
    [_imageView setImage:_imageList[_imageView.tag]];
    [_imageView.layer addAnimation:transition forKey:nil];
    }

  • 相关阅读:
    BZOJ 1013: [JSOI2008]球形空间产生器sphere
    BZOJ 1012: [JSOI2008]最大数maxnumber
    BZOJ 1011: [HNOI2008]遥远的行星
    BZOJ 1008: [HNOI2008]越狱
    BZOJ 1007: [HNOI2008]水平可见直线
    BZOJ 1003: [ZJOI2006]物流运输
    Spark core 总结
    SparkRDD算子(transformations算子和actions算子)
    SparkRDD算子初识
    初识Spark
  • 原文地址:https://www.cnblogs.com/yinqiang/p/3491382.html
Copyright © 2011-2022 走看看