fix: reblog avatar RTL support issue

This commit is contained in:
CMK 2021-03-10 14:06:08 +08:00
parent 1256ef1d8e
commit cd112c5102
1 changed files with 11 additions and 22 deletions

View File

@ -71,28 +71,17 @@ extension AvatarStackContainerButton {
let offset: CGFloat = 2 let offset: CGFloat = 2
let path: CGPath = { let path: CGPath = {
let path = CGMutablePath() let path = CGMutablePath()
path.addRect(CGRect(origin: .zero, size: AvatarStackContainerButton.containerSize)) path.addRect(CGRect(origin: .zero, size: AvatarStackedImageView.configurableAvatarImageSize))
if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft { let mirrorScale: CGFloat = UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft ? -1 : 1
path.addPath(UIBezierPath( path.addPath(UIBezierPath(
roundedRect: CGRect( roundedRect: CGRect(
x: AvatarStackedImageView.configurableAvatarImageSize.width + offset, x: mirrorScale * (AvatarStackContainerButton.containerSize.width - AvatarStackedImageView.configurableAvatarImageSize.width - offset),
y: AvatarStackContainerButton.containerSize.height - AvatarStackedImageView.configurableAvatarImageSize.height - offset, y: AvatarStackContainerButton.containerSize.height - AvatarStackedImageView.configurableAvatarImageSize.height - offset,
width: AvatarStackedImageView.configurableAvatarImageSize.width, width: AvatarStackedImageView.configurableAvatarImageSize.width,
height: AvatarStackedImageView.configurableAvatarImageSize.height height: AvatarStackedImageView.configurableAvatarImageSize.height
), ),
cornerRadius: AvatarStackedImageView.configurableAvatarImageCornerRadius cornerRadius: AvatarStackedImageView.configurableAvatarImageCornerRadius
).cgPath) ).cgPath)
} else {
path.addPath(UIBezierPath(
roundedRect: CGRect(
x: AvatarStackContainerButton.containerSize.width - AvatarStackedImageView.configurableAvatarImageSize.width - offset,
y: AvatarStackContainerButton.containerSize.height - AvatarStackedImageView.configurableAvatarImageSize.height - offset,
width: AvatarStackedImageView.configurableAvatarImageSize.width,
height: AvatarStackedImageView.configurableAvatarImageSize.height
),
cornerRadius: AvatarStackedImageView.configurableAvatarImageCornerRadius
).cgPath)
}
return path return path
}() }()
let maskShapeLayer = CAShapeLayer() let maskShapeLayer = CAShapeLayer()