Skip to content

Commit

Permalink
Merge pull request #1 from kfit-dev/ios-14-fix
Browse files Browse the repository at this point in the history
XCode 12 compatibility
  • Loading branch information
Berdikhan authored Oct 12, 2020
2 parents 1a49c41 + 7b8ffa6 commit 5a484f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion FPageControl.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FPageControl'
s.version = '0.6.0'
s.version = '0.7.0'
s.summary = 'Custom Page Control for Fave'

s.description = <<-DESC
Expand Down
25 changes: 21 additions & 4 deletions FPageControl/FPageControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@ -(void)prepareForInterfaceBuilder {

-(void)layoutSubviews {
[super layoutSubviews];
NSArray<UIView*> *subViews = self.subviews;
CGFloat mainWidth = self.frame.size.width;
CGFloat mainHeight = self.frame.size.height;
if (@available(iOS 14.0, *)) {
subViews = self.subviews.firstObject.subviews.firstObject.subviews;
mainWidth = self.subviews.firstObject.subviews.firstObject.frame.size.width;
mainHeight = self.subviews.firstObject.subviews.firstObject.frame.size.height;
}
NSInteger i = 0;
CGFloat width = self.dotSize * (CGFloat)(self.subviews.count + 3) + self.dotSpacing * (CGFloat)(self.subviews.count - 1);
CGFloat x = self.frame.size.width / 2 - (width / 2);
CGFloat y = self.frame.size.height / 2 - self.dotSize / 2;
for (UIView *view in self.subviews) {
CGFloat width = self.dotSize * (CGFloat)(subViews.count + 3) + self.dotSpacing * (CGFloat)(subViews.count - 1);
CGFloat x = mainWidth / 2 - (width / 2);
CGFloat y = mainHeight / 2 - self.dotSize / 2;
for (UIView *view in subViews) {
CGRect frame = view.frame;
frame.origin.x = x;
frame.origin.y = y;
Expand All @@ -59,10 +67,19 @@ -(void)layoutSubviews {
frame.size = CGSizeMake(self.dotSize, self.dotSize);
x += self.dotSize + self.dotSpacing;
}
if (@available(iOS 14.0, *)) {
((UIImageView*)view).image = nil;
if (self.currentPage == i) {
view.backgroundColor = self.currentPageIndicatorTintColor;
} else {
view.backgroundColor = self.pageIndicatorTintColor;
}
}
view.layer.cornerRadius = self.dotSize / 2;
view.frame = frame;
i += 1;
}

}

@end

0 comments on commit 5a484f2

Please sign in to comment.