Skip to content

Commit d93bbdd

Browse files
author
Felix Desiderato
committed
Merge branch 'fix/custom-view' into develop
2 parents 0c9ed3a + efed130 commit d93bbdd

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Sources/SwiftTooltipKit/Tooltip+Configuration.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public extension Tooltip {
4949
public var dismissAutomatically: Bool = false
5050
/// If `dismissAutomatically`is set to true, this can be used to set the time interval after which the tooltip is dismissed. Defaults to `2.5` seconds.
5151
public var timeToDimiss: TimeInterval = 2.5
52+
/// Optional Callback that is executed when the tooltip is dismissed.
53+
public var onDismiss: (() -> Void)? = nil
54+
/// Optional Callback that is executed when the tooltip is shown.
55+
public var onPresent: (() -> Void)? = nil
5256
/// Default init.
5357
public init() {}
5458
}

Sources/SwiftTooltipKit/Tooltip.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ open class Tooltip: UIView {
401401
options: configuration.animationConfiguration.animationOptions,
402402
animations: { [weak self] in
403403
self?.alpha = 0
404+
self?.configuration.onDismiss?()
404405
},
405406
completion: { [weak self] _ in
406407
self?.isHidden = true
@@ -416,14 +417,15 @@ open class Tooltip: UIView {
416417
delay: configuration.animationConfiguration.animationDelay,
417418
options: configuration.animationConfiguration.animationOptions,
418419
animations: { [unowned self] in
420+
self.configuration.onPresent?()
419421
self.alpha = 1
420422
}
421423
)
422424
}
423425

424426
private func warningMsg() -> String {
425427
"""
426-
LAYOUT ERROR:
428+
LAYOUT WARNING:
427429
428430
It seems that the view displayed as a tooltip is too large!
429431
Please make sure that size of the tooltip is valid and try again.

0 commit comments

Comments
 (0)