Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

fix displaced contentView and calculation of arc for drawBubbleRightShape #207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Sources/EasyTipView/EasyTipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ open class EasyTipView: UIView {
}

if case .view(let contentView) = content {
contentView.translatesAutoresizingMaskIntoConstraints = false
// When using `.view(contentView)`, pre-iOS 12 devices will have displaced text (outside of the "bubble").
// This ensures the view is within the bubble frame
if UIDevice.current.systemVersion.compare("12.0", options: String.CompareOptions.numeric) == ComparisonResult.orderedAscending {
contentView.translatesAutoresizingMaskIntoConstraints = true
} else {
contentView.translatesAutoresizingMaskIntoConstraints = false
}
contentView.frame = getContentRect(from: getBubbleFrame())
}

Expand Down Expand Up @@ -616,8 +622,7 @@ open class EasyTipView: UIView {
path.addArc(tangent1End: CGPoint(x: frame.x + frame.width, y: frame.y), tangent2End: CGPoint(x: frame.x, y: frame.y), radius: cornerRadius)
path.addArc(tangent1End: CGPoint(x: frame.x, y: frame.y), tangent2End: CGPoint(x: frame.x, y: frame.y + frame.height), radius: cornerRadius)
path.addArc(tangent1End: CGPoint(x: frame.x, y: frame.y + frame.height), tangent2End: CGPoint(x: frame.x + frame.width, y: frame.y + frame.height), radius: cornerRadius)
path.addArc(tangent1End: CGPoint(x: frame.x + frame.width, y: frame.y + frame.height), tangent2End: CGPoint(x: frame.x + frame.width, y: frame.height), radius: cornerRadius)

path.addArc(tangent1End: CGPoint(x: frame.x + frame.width, y: frame.y + frame.height), tangent2End: CGPoint(x: frame.x + frame.width, y: frame.y), radius: cornerRadius)
}

fileprivate func drawBubbleLeftShape(_ frame: CGRect, cornerRadius: CGFloat, path: CGMutablePath) {
Expand Down