#import <UIKit/UIKit.h> @interface YS_PageControl : UIPageControl @end ////////////////////////////////// #import "YS_PageControl.h" @implementation YS_PageControl //@synthesize activeImage; //@synthesize inactiveImage; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { } return self; } -(void) updateDots //通过便利子视图的数组更改选中或未选中的图片 { for (int i = 0; i < [self.subviews count]; i++) { UIImageView *dot = [self.subviews objectAtIndex:i];//需要学习的东西 CGPoint cen = dot.center; dot.frame = CGRectMake(0, 0, 7, 7); if (i == self.currentPage) { dot.image = [UIImage imageNamed:@"绿点.png"]; } else{ dot.image = [UIImage imageNamed:@"黑点.png"]; } dot.center = cen; } } -(void) setCurrentPage:(NSInteger)page //重写pageControl的currentPage { [super setCurrentPage:page]; [self updateDots]; } - (void)dealloc { [super dealloc]; } @end