UIImageView+RTL.m 927 B

12345678910111213141516171819202122232425
  1. //
  2. // UIImageView+RTL.m
  3. // BuguLive
  4. //
  5. // Created by voidcat on 2024/9/12.
  6. // Copyright © 2024 xfg. All rights reserved.
  7. //
  8. #import "UIImageView+RTL.h"
  9. #import "UIView+RTL.h"
  10. @implementation UIImage (RTL)
  11. - (UIImage *_Nonnull)checkOverturn {
  12. if ([UIView appearance].semanticContentAttribute == UISemanticContentAttributeForceRightToLeft) {
  13. UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale);
  14. CGContextRef bitmap = UIGraphicsGetCurrentContext();
  15. CGContextTranslateCTM(bitmap, self.size.width / 2, self.size.height / 2);
  16. CGContextScaleCTM(bitmap, -1.0, -1.0);
  17. CGContextTranslateCTM(bitmap, -self.size.width / 2, -self.size.height / 2);
  18. CGContextDrawImage(bitmap, CGRectMake(0, 0, self.size.width, self.size.height), self.CGImage);
  19. UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  20. return image;
  21. }
  22. return self;
  23. }
  24. @end