IOS--UIPageControl的使用方法详细

IOS--UIPageControl的使用方法详细

 

// UIPageControl的常用方法

    UIPageControl *onePageControl = [[UIPageControl alloc] init];

    onePageControl.frame = CGRectMake(10, 100, 300, 30); // 设置位置

    onePageControl.backgroundColor = [UIColor redColor]; // 设置背景色

    

    onePageControl.pageIndicatorTintColor = [UIColor whiteColor]; // 未选中的点的颜色

    onePageControl.currentPageIndicatorTintColor = [UIColor blueColor]; // 选中的点的颜色

    onePageControl.currentPage = 2; // 当前第几个点 默认0

    onePageControl.hidesForSinglePage = YES; // 如果页面只有1个的时候,指示器自动消失

    onePageControl.defersCurrentPageDisplay = NO; // 当你改变页面时,指示器是不会改变的,只有当你给updateCurrentPageDisplay发送消息才会改变现实, 默认是NO

    

    onePageControl.numberOfPages = 8; // 设置总共有多少个小点,也就是有多少个页面

    

    

    [self.view addSubview:onePageControl]; // 添加到View上

    [onePageControl release], onePageControl = nil; // 释放内存

原文地址:https://www.cnblogs.com/iOS-mt/p/4147806.html