Skip to content

Conversation

@iakash-singh
Copy link
Owner

@iakash-singh iakash-singh commented May 13, 2025

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 iakash-singh changed the title Replace deprecated UIGraphicsBeginImageContext with UIGraphicsImageRe… [TextControls] Replace UIGraphicsBeginImageContext with UIGraphicsImageRenderer in MDCTextControlGradientManager May 13, 2025
@iakash-singh iakash-singh merged commit 1a99def into develop May 13, 2025
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