Skip to content

[TextControls] Replace UIGraphicsBeginImageContext with UIGraphicsImageRenderer in MDCTextControlGradientManager #10288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

iakash-singh
Copy link

Overview

This PR updates the createImageWithLayer method in MDCTextControlGradientManager.m to use UIGraphicsImageRenderer instead of the deprecated UIGraphicsBeginImageContext API for rendering images from a CALayer. The change modernizes the codebase, improves performance, and aligns with Apple's recommended practices for iOS image rendering.

Changes

  • Replaced UIGraphicsBeginImageContext and related functions with UIGraphicsImageRenderer in MDCTextControlGradientManager.m (method: createImageWithLayer).
  • Ensured compatibility with existing functionality by maintaining the same input (CALayer) and output (UIImage).
  • No changes to public APIs or TextControls component behavior.

Why

  • UIGraphicsBeginImageContext is deprecated in iOS 17+ and generates warnings in modern Xcode versions.
  • UIGraphicsImageRenderer is the recommended API, offering better performance and support for modern iOS features (e.g., wide color, trait collections).

Testing

  • Manual Testing: Verified the updated method in the Catalog example app (Material Catalog). Confirmed that gradient images rendered for TextControls components are identical to the previous implementation.
  • Unit Tests: No existing unit tests were found for createImageWithLayer in MDCTextControlGradientManager. Manual testing was sufficient to validate the change.
  • Snapshot Tests: Confirmed that snapshot tests for TextControls components pass, ensuring no visual regressions.

Issues

  • No related GitHub issues identified.

iakash-singh and others added 2 commits May 14, 2025 01:46
[TextControls] Replace UIGraphicsBeginImageContext with UIGraphicsImageRenderer in MDCTextControlGradientManager
@iakash-singh iakash-singh requested a review from a team as a code owner May 13, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant