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

 

    文章標籤

    UIPageControl

    全站熱搜

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