iOS14UIpagecontrol的适配
2020-09-23 本文已影响0人
Jabne
1.SDCycleScrollView不显示UIpageControl的bug。
全局搜
self.pageControl.frame = CGRectMake(x, y, size.width, size.height);
替换为
if (@available(iOS 14.0, *)) {
[self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.bottom.offset(-10);
make.height.offset(self.pageControlDotSize.height);
}];
}else{
self.pageControl.frame = CGRectMake(x, y, size.width, size.height);
}
2.想要自定义小圆点的样式,遍历UIPageControl的子控件修改图片崩溃报错。
初始化UIPageControl的时候
page.preferredIndicatorImage = UIImage.init(named: "默认圆点")
[self.pageControl setCurrentPage:pageIndex]
的时候
if (@available(iOS 14.0, *)) {
for (int i = 0; i < self.pageControl.numberOfPages; i++) {
if (i == pageIndex) {
[self.pageControl setIndicatorImage:[UIImage imageNamed:@"选中圆点"] forPage:pageIndex];
}else{
[self.pageControl setIndicatorImage:[UIImage imageNamed:@"默认圆点"] forPage:i];
}
}
} else {
// Fallback on earlier versions
}