From 2389adeb55b68ef10a641448945b4bbb94383c9c Mon Sep 17 00:00:00 2001 From: gk <865425695@qq.com> Date: Sat, 24 Jun 2023 19:27:11 +0800 Subject: [PATCH] Fix tipViewSize and bubble height with left/right arrow positions --- Sources/EasyTipView/EasyTipView.swift | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/EasyTipView/EasyTipView.swift b/Sources/EasyTipView/EasyTipView.swift index 3d3e1be..fd0b271 100644 --- a/Sources/EasyTipView/EasyTipView.swift +++ b/Sources/EasyTipView/EasyTipView.swift @@ -359,12 +359,18 @@ open class EasyTipView: UIView { [unowned self] in - var tipViewSize = - CGSize( - width: self.contentSize.width + self.preferences.positioning.contentInsets.left + self.preferences.positioning.contentInsets.right + self.preferences.positioning.bubbleInsets.left + self.preferences.positioning.bubbleInsets.right, - height: self.contentSize.height + self.preferences.positioning.contentInsets.top + self.preferences.positioning.contentInsets.bottom + self.preferences.positioning.bubbleInsets.top + self.preferences.positioning.bubbleInsets.bottom + self.preferences.drawing.arrowHeight) - - return tipViewSize + let arrowPosition = preferences.drawing.arrowPosition + let width: CGFloat + let height: CGFloat + switch arrowPosition { + case .left, .right: + width = self.contentSize.width + self.preferences.positioning.contentInsets.left + self.preferences.positioning.contentInsets.right + self.preferences.positioning.bubbleInsets.left + self.preferences.positioning.bubbleInsets.right + self.preferences.drawing.arrowHeight + height = self.contentSize.height + self.preferences.positioning.contentInsets.top + self.preferences.positioning.contentInsets.bottom + self.preferences.positioning.bubbleInsets.top + self.preferences.positioning.bubbleInsets.bottom + default: + width = self.contentSize.width + self.preferences.positioning.contentInsets.left + self.preferences.positioning.contentInsets.right + self.preferences.positioning.bubbleInsets.left + self.preferences.positioning.bubbleInsets.right + height = self.contentSize.height + self.preferences.positioning.contentInsets.top + self.preferences.positioning.contentInsets.bottom + self.preferences.positioning.bubbleInsets.top + self.preferences.positioning.bubbleInsets.bottom + self.preferences.drawing.arrowHeight + } + return CGSize(width: width, height: height) }() // MARK: - Static variables - @@ -720,7 +726,7 @@ open class EasyTipView: UIView { case .left, .right: bubbleWidth = tipViewSize.width - preferences.positioning.bubbleInsets.left - preferences.positioning.bubbleInsets.right - preferences.drawing.arrowHeight - bubbleHeight = tipViewSize.height - preferences.positioning.bubbleInsets.top - preferences.positioning.bubbleInsets.left + bubbleHeight = tipViewSize.height - preferences.positioning.bubbleInsets.top - preferences.positioning.bubbleInsets.bottom bubbleXOrigin = arrowPosition == .right ? preferences.positioning.bubbleInsets.left : preferences.positioning.bubbleInsets.left + preferences.drawing.arrowHeight bubbleYOrigin = preferences.positioning.bubbleInsets.top