Toast & SvgSource
Two small platform globals: a transient notification, and a wrapper that turns raw SVG XML into an image source.
toast
toast(msg: string): voidShow a transient toast notification — a quick "Saved", "Copied", "No connection". Fire-and-forget; the host shows and dismisses it.
toast('Saved!')SvgSource
SvgSource(svg: string): { readonly svg: string, tintColor: string | null }Wrap a raw SVG XML string so it can be used wherever an image source is accepted (e.g. a
UIImage's src — see UI content). Set tintColor on the returned value to
recolor the SVG; null (the default) means untinted.
const icon = SvgSource('<svg viewBox="0 0 24 24"><path d="M12 2 L22 22 H2 Z"/></svg>')
icon.tintColor = '#4caf50'
const img = UIImage(icon)Note
importing a .svg file from the project does this for you — the compiler turns
import icon from './icon.svg' into a ready-made SvgSource value.
See also
- UI content —
UIImageand the full set of image sources - Networking —
FetchResponse/Fileas the other image sources