From 8214342f5b6f96030f21ded252fd62c113866b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E8=89=B2=E9=98=9F=E9=95=BF?= Date: Sat, 19 Dec 2020 17:14:56 +0800 Subject: [PATCH] Update TYViewStorage.m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增在 iOS 9 以上系统兼容 RTL 方向排版 --- TYAttributedLabelDemo/TYAttributedLabel/TYViewStorage.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TYAttributedLabelDemo/TYAttributedLabel/TYViewStorage.m b/TYAttributedLabelDemo/TYAttributedLabel/TYViewStorage.m index 4af2032..96862a1 100755 --- a/TYAttributedLabelDemo/TYAttributedLabel/TYViewStorage.m +++ b/TYAttributedLabelDemo/TYAttributedLabel/TYViewStorage.m @@ -45,6 +45,14 @@ - (void)drawStorageWithRect:(CGRect)rect // 设置frame 注意 转换rect CoreText context coordinates are the opposite to UIKit so we flip the bounds CGAffineTransform transform = CGAffineTransformScale(CGAffineTransformMakeTranslation(0, _superView.bounds.size.height), 1.f, -1.f); rect = CGRectApplyAffineTransform(rect, transform); + + //iOS 9 以上系统兼容 RTL 排版方向 + if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) { + if (UIUserInterfaceLayoutDirectionRightToLeft == [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:_superView.semanticContentAttribute]) { + rect.origin.x = rect.origin.x - rect.size.width; + } + } + [_view setFrame:rect]; [_superView addSubview:_view]; }