码迷,mamicode.com
首页 > 其他好文 > 详细

自定义PageControl样式

时间:2016-02-22 00:09:44      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:

#define iOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)
//调用方法  改变PageControl样式
[self changePageControlImage:self.detailPageControl];
//改变pagecontrol中圆点样式
- (void)changePageControlImage:(UIPageControl *)pageControl{
    static UIImage *currentImage = nil;
    static UIImage *otherImage = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        currentImage = [UIImage imageNamed:@"dot"];
        otherImage = [UIImage imageNamed:@"dotk"];
    });
    if (iOS7) {
        [pageControl setValue:currentImage forKey:@"_currentPageImage"];
        [pageControl setValue:otherImage forKey:@"_pageImage"];
    } else {
        for (int i = 0;i < self.thubmImageArray.count; i++) {
            UIImageView *imageVieW = [pageControl.subviews objectAtIndex:i];
            imageVieW.frame = CGRectMake(imageVieW.frame.origin.x, imageVieW.frame.origin.y, 20, 20);
            imageVieW.image = pageControl.currentPage == i ? currentImage : otherImage;
        }
    }
}
dotk@2x.png
dot@2x.png

 

自定义PageControl样式

标签:

原文地址:http://www.cnblogs.com/10-19-92/p/5205910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!