Use tooltips to show small unobtrusive hints on top of your app's UI. These can appear as a result of user interaction, or be triggered thoughtfully to assist the user in learning the details of a new feature they have shown interest in.
Variations: The tooltip can have an optional title and the tip of the tooltip can point up, down, left, or right.
Message Only | Message and Title |
---|---|
Up | Down | Left | Right |
---|---|---|---|
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 */ })
- 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.
Tooltip
in Swift, MSFTooltip
in Objective-C/UIKit