Преглед изворни кода

Prefer new imageWithTintColor API when tinting an UIImage (#5458)

With this change, dynamic colors will be supported when tinting an image and the image color will change on the fly depending on the dynamic provider and traits. This will be especially useful when supporting the new dark mode in iOS 13.
Danilo Bürger пре 5 година
родитељ
комит
5d751f643a
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5
    0
      lib/ios/UIImage+tint.m

+ 5
- 0
lib/ios/UIImage+tint.m Прегледај датотеку

@@ -4,6 +4,11 @@
4 4
 
5 5
 - (UIImage *)withTintColor:(UIColor *)color {
6 6
 	UIImage *newImage = [self imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
7
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
8
+	if (@available(iOS 13.0, *)) {
9
+		return [newImage imageWithTintColor:color];
10
+	}
11
+#endif
7 12
 	UIGraphicsBeginImageContextWithOptions(self.size, NO, newImage.scale);
8 13
 	[color set];
9 14
 	[newImage drawInRect:CGRectMake(0, 0, self.size.width, newImage.size.height)];