-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZYPageControl.m
75 lines (63 loc) · 1.74 KB
/
ZYPageControl.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// ZYPageControl.m
// DownLoader
//
// Created by zY on 16/2/26.
// Copyright © 2016年 chai. All rights reserved.
//
#import "ZYPageControl.h"
@interface ZYPageControl ()
{
UIImage *imageNormal;
UIImage *imageCurrent;
BOOL isFirstLaunch;
}
@end
@implementation ZYPageControl
-(instancetype) initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
isFirstLaunch = YES;
imageNormal = [UIImage imageNamed:@"rayark_page"];
imageCurrent = [UIImage imageNamed:@"rayark_page_current"];
}
return self;
}
-(instancetype)init
{
self = [super init];
if (self) {
isFirstLaunch = YES;
imageNormal = [UIImage imageNamed:@"rayark_page"];
imageCurrent = [UIImage imageNamed:@"rayark_page_current"];
}
return self;
}
-(void) updateDots {
for (int i=0; i<self.subviews.count; i++) {
UIView *view = self.subviews[i];
CGSize size;
size.height = 10; //自定义圆点的大小
size.width = 10; //自定义圆点的大小
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, size.width, size.width)];
view.layer.cornerRadius = 5;
UIImageView *imageview = [view viewWithTag:100+i];
if (imageview == nil) {
UIImageView *dot = [[UIImageView alloc] initWithFrame:view.bounds];
dot.tag = 100+i;
[view addSubview:dot];
}
if (i == self.currentPage) {
imageview.image =imageCurrent;
}else{
imageview.image = imageNormal;
}
}
}
-(void) setCurrentPage:(NSInteger)page
{
[super setCurrentPage:page];
[self updateDots];
}
@end