UIPageControl用於提示此用者此頁面有多重顯示,

此元件的行為類似翻頁的動作,

本範例為放置三張圖片,點擊UIPageControl替換圖片顯示

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *myImage;
- (IBAction)pageChanged:(UIPageControl*)sender;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)pageChanged:(UIPageControl*)sender {
    
    _myImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"photo%ld.jpg",sender.currentPage+1]];
    
}
@end

 

arrow
arrow
    文章標籤
    UIPageControl
    全站熱搜
    創作者介紹
    創作者 Will 的頭像
    Will

    Will的部落格

    Will 發表在 痞客邦 留言(0) 人氣()