yysskk / SwipeMenuViewController

Swipable tab and menu View and ViewController.
MIT License
1.29k stars 131 forks source link

Update TabView to accept NSAttributedString #113

Closed richard-ash closed 1 year ago

richard-ash commented 3 years ago

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.