51 lines
1.2 KiB
Objective-C
51 lines
1.2 KiB
Objective-C
//
|
|
// GiGaPageControl.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/10/8.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "GiGaPageControl.h"
|
|
|
|
@implementation GiGaPageControl
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
_defalutImage = [UIImage imageNamed:@"pagecontrol_def"];
|
|
_currentImage = [UIImage imageNamed:@"pagecontrol_current"];
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)updateDots{
|
|
|
|
for (int i =0; i<self.subviews.count; i++) {
|
|
UIView *dot = [self.subviews objectAtIndex:i];
|
|
dot.backgroundColor = [UIColor clearColor];
|
|
UIImageView *imageview = [[UIImageView alloc] init];
|
|
if (i == self.currentPage) {
|
|
imageview.image = _currentImage;
|
|
imageview.frame = CGRectMake(0, 0, 26, 8);
|
|
}else{
|
|
imageview.image = _defalutImage;
|
|
imageview.frame = CGRectMake(0,0,8, 8);
|
|
}
|
|
|
|
for (UIView *subViews in dot.subviews) {
|
|
[subViews removeFromSuperview];
|
|
}
|
|
[dot addSubview:imageview];
|
|
}
|
|
}
|
|
|
|
-(void)setCurrentPage:(NSInteger)currentPage
|
|
{
|
|
[super setCurrentPage:currentPage];
|
|
[self updateDots];
|
|
}
|
|
|
|
@end
|