ios中简单的图片滚动实现

- (void)setupScrollView {

    UIScrollView *scrollView = [[UIScrollView alloc] init];

    CGRect bounds = self.view.bounds;

    scrollView.frame = bounds;

    CGFloat newFeatureImageWidth = self.view.bounds.size.width;

    for (int i = 0; i < NewFeatureImageCount; ++i) {

        NSString *newFeatureImageName = [NSString stringWithFormat:@"new_feature_%d", i + 1];

        UIImage *newFeatureImage = [UIImage imageNamed:newFeatureImageName];

        UIImageView *imageView = [[UIImageView alloc] initWithImage:newFeatureImage];

        imageView.frame = (CGRect) {{newFeatureImageWidth * i, 0}, bounds.size};

        if (i == NewFeatureImageCount - 1) {

            [self setupStart:imageView];

        }

        [scrollView addSubview:imageView];

    }

    scrollView.contentSize = CGSizeMake(newFeatureImageWidth * NewFeatureImageCount, 0);

    scrollView.showsHorizontalScrollIndicator = NO;

    scrollView.pagingEnabled = YES;

    scrollView.bounces = NO;

    scrollView.delegate = self;

    [self.view addSubview:scrollView];





}

你可能感兴趣的:(ios,图片,iPhone,轮播)