@@ -236,8 +236,7 @@ open class PuiSegmentedControl: UIControl {
236236
237237 // Set corner radius
238238 self . selectedView. layer. masksToBounds = true
239- self . changeSelectedViewCornerRadius ( index: self . selectedIndex,
240- cornerRadius: self . borderCornerRadius)
239+ self . changeSelectedViewCornerRadius ( index: self . selectedIndex)
241240
242241 // Add sublayer
243242 self . addSubview ( self . selectedView)
@@ -351,12 +350,13 @@ open class PuiSegmentedControl: UIControl {
351350 // MARK: - Changed Segment Actions.
352351
353352 // Set radius of the segment's according to index and positions.
354- private func changeSelectedViewCornerRadius( index: Int , cornerRadius : CGFloat ) {
353+ private func changeSelectedViewCornerRadius( index: Int ) {
355354 // Set zero
356355 self . selectedView. layer. cornerRadius = 0
357356
358357 // Calculate difference
359- let calculatedCornerRadius = cornerRadius - ( self . borderWidth + self . selectedViewMargins. top)
358+ let calculatedCornerRadius = self . borderCornerRadius -
359+ ( self . borderWidth + ( ( self . selectedViewMargins. top + self . selectedViewMargins. bottom) / 2 ) )
360360
361361 // Check required status.
362362 if self . isSelectViewAllCornerRadius {
@@ -380,8 +380,7 @@ open class PuiSegmentedControl: UIControl {
380380 self . configureSelectedViewFrame ( )
381381
382382 // Setup corners
383- self . changeSelectedViewCornerRadius ( index: self . selectedIndex,
384- cornerRadius: self . borderCornerRadius)
383+ self . changeSelectedViewCornerRadius ( index: self . selectedIndex)
385384
386385 // Change attributes
387386 self . labels [ oldValue] . isSelected = false
0 commit comments