最終效果圖:

BeyondViewController.h
// // BeyondViewController.h // 8_scrollVIew分頁浏覽 // // Created by beyond on 14-7-25. // Copyright (c) 2014年 com.beyond. All rights reserved. // #import@interface BeyondViewController : UIViewController @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; @end
BeyondViewController.m
//
// BeyondViewController.m
// 8_scrollVIew分頁浏覽
/*
以下代碼存在性能問題,僅作為新特性介紹界面使用
不可作為圖片浏覽器~
1,一次性生成8個ImageView會存在性能問題,解決方法:使用3個ImageView(或2個ImageView)
2,另外,循環播放還沒實現
*/
// Created by beyond on 14-7-25.
// Copyright (c) 2014年 com.beyond. All rights reserved.
//
#import "BeyondViewController.h"
// 圖片總張數
#define kImgCount 8
@interface BeyondViewController ()
{
// 分頁條碼指示控制器
UIPageControl *_pageControl;
}
@end
@implementation BeyondViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// 調用自定義方法
[self scrollViewWithPage];
}
// 帶分頁功能的scrollView
- (void)scrollViewWithPage
{
// 1,設置scrollView的可視大小,內容大小,等屬性
_scrollView.frame = self.view.bounds;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.bouncesZoom = NO;
_scrollView.bounces = NO;
// 設置代碼,監聽滾動完畢的事件
_scrollView.delegate = self;
// 2,創建8個UIImageView,添加到scrollView
// 每個圖片寬,高
CGFloat imgW = self.view.bounds.size.width;
CGFloat imgH = self.view.bounds.size.height;
for (int i=0; i