Jay*_*yas 1 objective-c uitabbarcontroller ios swift swift3
如何快速获得 UITabBar 项目的选定索引我不是在谈论UITabBarController。
我知道我可以使用 UITabBarItem.tag。
但对我来说,我不能为选定的索引使用标签,因为它已经用于其他目的。有没有其他方法可以快速获取所选选项卡的索引。
https://developer.apple.com/documentation/uikit/uitabbar
UITabBar 有 2 个属性“items”和“selectedItem”,都是 UITabBarItem 类型。
因此,您可以通过获取“items”中“selectedItem”的索引来获取所选项目的索引。
items.index(of: selectedItem)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1869 次 |
最近记录: |