@@ -134,13 +134,11 @@ extension MainTabBarController {
134134
135135 func showDotOn( _ tab: WooTab ) {
136136 hideDotOn ( tab)
137- let dot = UIView ( frame: CGRect ( x: DotConstants . xOffset,
138- y: DotConstants . yOffset,
139- width: DotConstants . diameter,
140- height: DotConstants . diameter) )
137+ let dot = GreenDotView ( frame: CGRect ( x: DotConstants . xOffset,
138+ y: DotConstants . yOffset,
139+ width: DotConstants . diameter,
140+ height: DotConstants . diameter) , borderWidth : DotConstants . borderWidth )
141141 dot. tag = dotTag ( for: tab)
142- dot. backgroundColor = StyleManager . wooAccent
143- dot. layer. cornerRadius = ( DotConstants . diameter / 2 )
144142 tabBar. subviews [ tab. rawValue] . subviews. first? . insertSubview ( dot, at: 1 )
145143 }
146144
@@ -164,9 +162,50 @@ extension MainTabBarController {
164162private extension MainTabBarController {
165163
166164 enum DotConstants {
167- static let diameter = CGFloat ( 9 )
168- static let xOffset = CGFloat ( 3 )
169- static let yOffset = CGFloat ( 1 )
170- static let tagOffset = 999
165+ static let diameter = CGFloat ( 10 )
166+ static let borderWidth = CGFloat ( 1 )
167+ static let xOffset = CGFloat ( 2 )
168+ static let yOffset = CGFloat ( 0 )
169+ static let tagOffset = 999
170+ }
171+ }
172+
173+
174+ // MARK: - GreenDot UIView
175+ //
176+ private class GreenDotView : UIView {
177+
178+ private var borderWidth = CGFloat ( 1 ) // Border line width defaults to 1
179+
180+ /// Designated Initializer
181+ ///
182+ init ( frame: CGRect , borderWidth: CGFloat ) {
183+ super. init ( frame: frame)
184+ self . borderWidth = borderWidth
185+ setupSubviews ( )
186+ }
187+
188+ /// Required Initializer
189+ ///
190+ required init ? ( coder aDecoder: NSCoder ) {
191+ super. init ( coder: aDecoder)
192+ setupSubviews ( )
193+ }
194+
195+ private func setupSubviews( ) {
196+ self . backgroundColor = . clear
197+ }
198+
199+ override func draw( _ rect: CGRect ) {
200+ let path = UIBezierPath ( ovalIn: CGRect ( x: rect. origin. x + borderWidth,
201+ y: rect. origin. y + borderWidth,
202+ width: rect. size. width - borderWidth*2,
203+ height: rect. size. width - borderWidth*2) )
204+ StyleManager . wooAccent. setFill ( )
205+ path. fill ( )
206+
207+ path. lineWidth = borderWidth
208+ StyleManager . wooWhite. setStroke ( )
209+ path. stroke ( )
171210 }
172211}
0 commit comments