。h文件
#import <UIKit/UIKit.h>
@interface MyPageControl : UIPageControl{
UIImage* activeImage;
UIImage* inactiveImage;
}
@end
。m文件#import "MyPageControl.h"
@implementation MyPageControl
-(id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
activeImage = [[UIImage imageNamed:@"page_select_s3.png"] retain];
inactiveImage = [[UIImage imageNamed:@"page_select_s5.png"] retain];
[self setCurrentPage:1];
return self;
}
-(void) updateDots
{
for (int i = 0; i < [self.subviews count]; i++)
{
UIImageView* dot = [self.subviews objectAtIndex:i];
if (i == self.currentPage) dot.image = activeImage;
else dot.image = inactiveImage;
}
}
-(void) setCurrentPage:(NSInteger)page
{
[super setCurrentPage:page];
[self updateDots];
}
-(void)dealloc
{
[super dealloc];
}
@end