@@ -42,6 +42,9 @@ public class SSTabConfiguration {
42
42
/// Reverse Curve
43
43
public var reverseCurve : Bool
44
44
45
+ /// Selected index
46
+ public var selectedIndex : Int
47
+
45
48
/// Initializer for Tabbar configuration
46
49
/// - Parameters:
47
50
/// - barHeight: Bar height
@@ -53,7 +56,21 @@ public class SSTabConfiguration {
53
56
/// - shadowColor: Shadow Color
54
57
/// - shadowRadius: Shadow Radius
55
58
/// - shadowOffset: Shadow Offset
56
- public init ( barHeight: CGFloat ? = nil , upAnimationPoint: CGFloat ? = nil , layerFillColor: UIColor = . white, waveHeight: CGFloat = 17 , selectedTabTintColor: UIColor = UIColor . orange, unselectedTabTintColor: UIColor = . black, shadowColor: UIColor = . black, shadowRadius: CGFloat = . zero, shadowOffset: CGSize = CGSize ( width: 0 , height: - 1 ) , reverseCurve: Bool = false ) {
59
+ /// - reverseCurve: Set reverse curve
60
+ /// - selectedIndex: Index of selected tabbar item
61
+ public init (
62
+ barHeight: CGFloat ? = nil ,
63
+ upAnimationPoint: CGFloat ? = nil ,
64
+ layerFillColor: UIColor = . white,
65
+ waveHeight: CGFloat = 17 ,
66
+ selectedTabTintColor: UIColor = UIColor . orange,
67
+ unselectedTabTintColor: UIColor = . black,
68
+ shadowColor: UIColor = . black,
69
+ shadowRadius: CGFloat = . zero,
70
+ shadowOffset: CGSize = CGSize ( width: 0 , height: - 1 ) ,
71
+ reverseCurve: Bool = false ,
72
+ selectedIndex: Int = 0
73
+ ) {
57
74
self . barHeight = barHeight
58
75
self . upAnimationPoint = upAnimationPoint
59
76
self . layerFillColor = layerFillColor
@@ -64,6 +81,7 @@ public class SSTabConfiguration {
64
81
self . shadowRadius = shadowRadius
65
82
self . shadowOffset = shadowOffset
66
83
self . reverseCurve = reverseCurve
84
+ self . selectedIndex = selectedIndex
67
85
}
68
86
69
87
}
@@ -169,6 +187,10 @@ public struct SwiftUITabBarController: UIViewControllerRepresentable {
169
187
tabBar. tintColor = configuration. selectedTabTintColor
170
188
tabBar. isHidden = isTabBarHidden
171
189
tabBar. reverseCurve = configuration. reverseCurve
190
+ if let viewControllers = tabBarVC. viewControllers,
191
+ configuration. selectedIndex <= viewControllers. count {
192
+ tabBarVC. selectedIndex = configuration. selectedIndex
193
+ }
172
194
}
173
195
174
196
public static func refreshViews( ) {
0 commit comments