Tooltip Preview
A tooltip provides supplemental, contextual information without shifting people’s focus away from the primary interface. Use them to give helpful but non-essential plain text hints.
Tooltips are especially helpful for teaching someone how to use your app. If you need to provide a list of actions, try a popup menu. If you need to let someone know the status of the system or a task, try a banner or toast notification.
Usage
Displays a tooltip based on the current settings, pointing to the supplied anchorView. If another tooltip view is already showing, it will be dismissed and the new tooltip will be shown.
Tooltip.shared.show(with: "This is the message of the tooltip.",
title: "This is the title of the tooltip.",
for: sender,
preferredArrowDirection: .up,
offset: CGPoint(x: 0, y: 0),
dismissOn: .tapAnywhere,
onTap: { /* Action after Tapping */ })
Properties
message
The text to be displayed on the new tooltip view.
title
The optional bolded text to be displayed above the message on the new tooltip view.
anchorView
The view to point to with the new tooltip’s arrow.
preferredArrowDirection
The preferred direction for the tooltip’s arrow. Only the arrow’s axis is guaranteed; the direction may be changed based on available space between the anchorView and the screen’s margins. Defaults to down.
offset
An offset from the tooltip’s default position.
dismissMode
The mode of tooltip dismissal. Defaults to tapping anywhere.
onTap
An optional closure used to do work after the user taps.
Implementation
Control name
Tooltip
in Swift,
MSFTooltip
in Objective-C.