// // PIPageControl.m // YuMi // // Created by duoban on 2023/10/8. // #import "PIPageControl.h" @implementation PIPageControl -(void)setNumberOfPages:(NSInteger)numberOfPages{ _numberOfPages = numberOfPages; for (int i = 0; i < _numberOfPages; i++) { UIView *dosView = [[UIView alloc]init]; dosView.tag = 100 + i; [self addSubview:dosView]; CGFloat left = i * kGetScaleWidth(7); [dosView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(kGetScaleWidth(4)); make.top.equalTo(self); make.left.mas_equalTo(left); }]; dosView.layer.cornerRadius = kGetScaleWidth(4)/2; dosView.layer.masksToBounds = YES; } } - (void)setCurrentPage:(NSInteger)currentPage{ _currentPage = currentPage; for (int i = 0; i < _numberOfPages; i++) { UIView *dosView = [self viewWithTag:100 + i]; dosView.backgroundColor = _currentPage == i ? _currentPageIndicatorTintColor : _pageIndicatorTintColor; } } @end