diff --git a/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift b/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift index 8893eca..914642e 100644 --- a/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift +++ b/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift @@ -8,6 +8,10 @@ import UIKit import FireworkVideo import AVFoundation +private let gNamesOfImagesWithDirection: [String] = [ + "c3RyZWFtLWdhdGUtYmFjaw==".decodeBase64String(), +] + extension UIView { static func swizzleViewMethodsForAppLanguage() { Swizzle.swizzleSelector( @@ -61,6 +65,33 @@ extension UIView { } DispatchQueue.main.async { + if AppLanguageManager.shared.shouldHorizontalFlip { + let swiftUIImageLayerClassName = "SW1hZ2VMYXllcg==".decodeBase64String() + let swiftUITextLayerClassName = "Q0dEcmF3aW5nTGF5ZXI=".decodeBase64String() + let layerClassName = String(describing: type(of: self.layer)) + if layerClassName == swiftUITextLayerClassName { + view.viewType = .normal + } else if layerClassName == swiftUIImageLayerClassName { + var resultViewType = LayoutFlipViewType.normal + if let contents = self.layer.contents as? CFTypeRef, + CFGetTypeID(contents) == CGImage.typeID { + let image = self.layer.contents as! CGImage + for imageName in gNamesOfImagesWithDirection { + let imageWithDirection = UIImage( + named: imageName, + in: Bundle(for: FireworkVideoSDK.self), + compatibleWith: nil + )?.cgImage + if image == imageWithDirection { + resultViewType = .flip + break + } + } + } + view.viewType = resultViewType + } + } + if view.layer.sublayers?.first(where: { layer in layer is AVPlayerLayer }) != nil, AppLanguageManager.shared.shouldHorizontalFlip { diff --git a/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift b/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift index c23bb00..9577206 100644 --- a/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +++ b/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift @@ -17,8 +17,8 @@ private let gNoFlipClasses: [Any] = [ "PUPhotosSectionHeaderContentView", "UITableViewIndex", "UIWebView", - "X1VJUmVtb3RlVmlldw==".decodeBase64String(), // _UIRemoteView - "VUlBdXRvY29ycmVjdFRleHRWaWV3".decodeBase64String() // UIAutocorrectTextView + "X1VJUmVtb3RlVmlldw==".decodeBase64String(), + "VUlBdXRvY29ycmVjdFRleHRWaWV3".decodeBase64String(), ] enum LayoutFlipViewType: Int { @@ -151,7 +151,11 @@ extension UIView { let shouldSetFlipTransform = shouldFlipSuperview != shouldFlipCurrentView if shouldSetFlipTransform && LayoutFlipManager.shared.enableHorizontalFlip { - layer.basicTransform = CGAffineTransformMakeScale(-1, 1) + if layer.anchorPoint == CGPointZero { + layer.basicTransform = CGAffineTransformConcat(CGAffineTransformMakeScale(-1, 1), CGAffineTransform(translationX: layer.bounds.width, y: 0)) + } else { + layer.basicTransform = CGAffineTransformMakeScale(-1, 1) + } } else { layer.basicTransform = CGAffineTransformIdentity }