diff --git a/Objective-C/TOCropViewController/Views/TOCropToolbar.m b/Objective-C/TOCropViewController/Views/TOCropToolbar.m index cea84e3f..1bf95264 100644 --- a/Objective-C/TOCropViewController/Views/TOCropToolbar.m +++ b/Objective-C/TOCropViewController/Views/TOCropToolbar.m @@ -78,7 +78,11 @@ - (void)setup { nil) forState:UIControlStateNormal]; [_doneTextButton setTitleColor:[UIColor colorWithRed:1.0f green:0.8f blue:0.0f alpha:1.0f] forState:UIControlStateNormal]; - [_doneTextButton.titleLabel setFont:[UIFont systemFontOfSize:17.0f]]; + if (@available(iOS 13.0, *)) { + [_doneTextButton.titleLabel setFont:[UIFont systemFontOfSize:17.0f weight:UIFontWeightMedium]]; + } else { + [_doneTextButton.titleLabel setFont:[UIFont systemFontOfSize:17.0f]]; + } [_doneTextButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; [_doneTextButton sizeToFit]; [self addSubview:_doneTextButton]; @@ -284,12 +288,16 @@ - (void)layoutToolbarButtons:(NSArray *)buttons withSameButtonSize:(CGSize)size CGFloat padding = (maxLength - fixedSize * count) / (count + 1); for (NSInteger i = 0; i < count; i++) { - UIView *button = buttons[i]; + UIButton *button = buttons[i]; CGFloat sameOffset = horizontally ? fabs(CGRectGetHeight(containerRect)-CGRectGetHeight(button.bounds)) : fabs(CGRectGetWidth(containerRect)-CGRectGetWidth(button.bounds)); CGFloat diffOffset = padding + i * (fixedSize + padding); CGPoint origin = horizontally ? CGPointMake(diffOffset, sameOffset) : CGPointMake(sameOffset, diffOffset); if (horizontally) { origin.x += CGRectGetMinX(containerRect); + if (@available(iOS 13.0, *)) { + UIImage *image = button.imageView.image; + button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, image.baselineOffsetFromBottom, 0); + } } else { origin.y += CGRectGetMinY(containerRect); } @@ -407,6 +415,11 @@ - (void)setDoneTextButtonTitle:(NSString *)doneTextButtonTitle { #pragma mark - Image Generation - + (UIImage *)doneImage { + if (@available(iOS 13.0, *)) { + return [UIImage systemImageNamed:@"checkmark" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]]; + } + UIImage *doneImage = nil; UIGraphicsBeginImageContextWithOptions((CGSize){17,14}, NO, 0.0f); @@ -430,6 +443,11 @@ + (UIImage *)doneImage + (UIImage *)cancelImage { + if (@available(iOS 13.0, *)) { + return [UIImage systemImageNamed:@"xmark" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]]; + } + UIImage *cancelImage = nil; UIGraphicsBeginImageContextWithOptions((CGSize){16,16}, NO, 0.0f); @@ -459,6 +477,12 @@ + (UIImage *)cancelImage + (UIImage *)rotateCCWImage { + if (@available(iOS 13.0, *)) { + return [[UIImage systemImageNamed:@"rotate.left.fill" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]] + imageWithBaselineOffsetFromBottom:4]; + } + UIImage *rotateImage = nil; UIGraphicsBeginImageContextWithOptions((CGSize){18,21}, NO, 0.0f); @@ -496,6 +520,12 @@ + (UIImage *)rotateCCWImage + (UIImage *)rotateCWImage { + if (@available(iOS 13.0, *)) { + return [[UIImage systemImageNamed:@"rotate.right.fill" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]] + imageWithBaselineOffsetFromBottom:4]; + } + UIImage *rotateCCWImage = [self.class rotateCCWImage]; UIGraphicsBeginImageContextWithOptions(rotateCCWImage.size, NO, rotateCCWImage.scale); CGContextRef context = UIGraphicsGetCurrentContext(); @@ -509,6 +539,12 @@ + (UIImage *)rotateCWImage + (UIImage *)resetImage { + if (@available(iOS 13.0, *)) { + return [[UIImage systemImageNamed:@"arrow.counterclockwise" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]] + imageWithBaselineOffsetFromBottom:0];; + } + UIImage *resetImage = nil; UIGraphicsBeginImageContextWithOptions((CGSize){22,18}, NO, 0.0f); @@ -553,6 +589,12 @@ + (UIImage *)resetImage + (UIImage *)clampImage { + if (@available(iOS 13.0, *)) { + return [[UIImage systemImageNamed:@"aspectratio.fill" + withConfiguration:[UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]] + imageWithBaselineOffsetFromBottom:0]; + } + UIImage *clampImage = nil; UIGraphicsBeginImageContextWithOptions((CGSize){22,16}, NO, 0.0f);