diff --git a/components/TextFields/src/MDCTextInputControllerLegacyDefault.m b/components/TextFields/src/MDCTextInputControllerLegacyDefault.m index 1036184760e..8a726e834ae 100644 --- a/components/TextFields/src/MDCTextInputControllerLegacyDefault.m +++ b/components/TextFields/src/MDCTextInputControllerLegacyDefault.m @@ -79,12 +79,14 @@ - (UIImage *)drawnClearButtonImage:(UIColor *)color { CGFloat scale = [UIScreen mainScreen].scale; CGRect bounds = CGRectMake(0, 0, clearButtonSize.width * scale, clearButtonSize.height * scale); - UIGraphicsBeginImageContextWithOptions(bounds.size, false, scale); - [color setFill]; - - [MDCPathForClearButtonLegacyImageFrame(bounds) fill]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init]; + format.scale = scale; + UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:bounds.size format:format]; + UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { + [color setFill]; + + [MDCPathForClearButtonLegacyImageFrame(bounds) fill]; + }]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; return image; diff --git a/components/TextFields/src/MDCTextInputControllerLegacyFullWidth.m b/components/TextFields/src/MDCTextInputControllerLegacyFullWidth.m index da2ffb3e1d0..1286c4f2a3d 100644 --- a/components/TextFields/src/MDCTextInputControllerLegacyFullWidth.m +++ b/components/TextFields/src/MDCTextInputControllerLegacyFullWidth.m @@ -57,12 +57,14 @@ - (UIImage *)drawnClearButtonImage:(UIColor *)color { CGFloat scale = [UIScreen mainScreen].scale; CGRect bounds = CGRectMake(0, 0, clearButtonSize.width * scale, clearButtonSize.height * scale); - UIGraphicsBeginImageContextWithOptions(bounds.size, false, scale); - [color setFill]; + UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init]; + format.scale = scale; + UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:bounds.size format:format]; + UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { + [color setFill]; - [MDCPathForClearButtonLegacyImageFrame(bounds) fill]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + [MDCPathForClearButtonLegacyImageFrame(bounds) fill]; + }]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; return image; diff --git a/components/TextFields/src/private/MDCTextInputCommonFundament.m b/components/TextFields/src/private/MDCTextInputCommonFundament.m index 5fc4cb0eda7..fcb17e3826a 100644 --- a/components/TextFields/src/private/MDCTextInputCommonFundament.m +++ b/components/TextFields/src/private/MDCTextInputCommonFundament.m @@ -627,12 +627,12 @@ - (UIImage *)drawnClearButtonImage { MDCTextInputClearButtonImageSquareWidthHeight); CGRect bounds = CGRectMake(0, 0, clearButtonSize.width, clearButtonSize.height); - UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0); - [UIColor.grayColor setFill]; - - [MDCPathForClearButtonImageFrame(bounds) fill]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:bounds.size]; + UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { + [UIColor.grayColor setFill]; + + [MDCPathForClearButtonImageFrame(bounds) fill]; + }]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; return image;