系统自带的UIPageControl,点的颜色单调,所以自定义一下。
#import <UIKit/UIKit.h>
@interface SJGreenControl : UIPageControl
{
UIImage*_activeImage;
UIImage*_inactiveImage;
}
@end
#import "SJGreenControl.h"
@implementation SJGreenControl
- (id)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self) {
_activeImage= [UIImageimageNamed:@"btn_round_selected"];
_inactiveImage= [UIImageimageNamed:@"btn_round_unselected"];
}
returnself;
}
- (void)updateDots
{
for(int i = 0; i< [self.subviewscount]; i++) {
UIImageView* dot = [self.subviewsobjectAtIndex:i];
if(i == self.currentPage){
dot.image= _activeImage;
}
else
dot.image= _inactiveImage;
}
}
- (void)setCurrentPage:(NSInteger)currentPage
{
[supersetCurrentPage:currentPage];
[selfupdateDots];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end