Here I update the TabView to accept NSAttributedString in lieu of String.
This enables quite a bit more flexibility with what you add as the title to the tab bar. For instance, one can now add images using the NSTextAttachment.
Regarding implementation, I have the TabView prefer func tabView(_ tabView: TabView, titleForItemAt index: Int) -> String? over func tabView(_ tabView: TabView, attributedTitleForItemAt index: Int) -> NSAttributedString?, so if you implement both dataSource methods for a given index it will use the original.
Here I update the
TabView
to acceptNSAttributedString
in lieu ofString
.This enables quite a bit more flexibility with what you add as the title to the tab bar. For instance, one can now add images using the
NSTextAttachment
.Regarding implementation, I have the
TabView
preferfunc tabView(_ tabView: TabView, titleForItemAt index: Int) -> String?
overfunc tabView(_ tabView: TabView, attributedTitleForItemAt index: Int) -> NSAttributedString?
, so if you implement both dataSource methods for a given index it will use the original.