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

Add arrowPadding #221

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
9 changes: 5 additions & 4 deletions Sources/EasyTipView/EasyTipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ open class EasyTipView: UIView {
public var foregroundColor = UIColor.white
public var backgroundColor = UIColor.red
public var arrowPosition = ArrowPosition.any
public var arrowPadding = CGFloat(0)
public var textAlignment = NSTextAlignment.center
public var borderWidth = CGFloat(0)
public var borderColor = UIColor.clear
Expand Down Expand Up @@ -441,16 +442,16 @@ open class EasyTipView: UIView {
switch position {
case .top, .any:
xOrigin = refViewFrame.center.x - tipViewSize.width / 2
yOrigin = refViewFrame.y + refViewFrame.height
yOrigin = refViewFrame.y + refViewFrame.height + preferences.drawing.arrowPadding
case .bottom:
xOrigin = refViewFrame.center.x - tipViewSize.width / 2
yOrigin = refViewFrame.y - tipViewSize.height
yOrigin = refViewFrame.y - tipViewSize.height - preferences.drawing.arrowPadding
case .right:
xOrigin = refViewFrame.x - tipViewSize.width
yOrigin = refViewFrame.center.y - tipViewSize.height / 2
yOrigin = refViewFrame.center.y - tipViewSize.height / 2 + preferences.drawing.arrowPadding
case .left:
xOrigin = refViewFrame.x + refViewFrame.width
yOrigin = refViewFrame.center.y - tipViewSize.height / 2
yOrigin = refViewFrame.center.y - tipViewSize.height / 2 - preferences.drawing.arrowPadding
}

var frame = CGRect(x: xOrigin, y: yOrigin, width: tipViewSize.width, height: tipViewSize.height)
Expand Down