Increase distance between inner view and segmented control layer

Viewed 341

I have segmented control in my app. So far I make it like in image below:

image

Is there any way to change distance between layer of inner view (white view for selected segment) and layer of segmented control to make it like in the following image?

image2

Here is my code for segmented control:

private let segmentedControl: UISegmentedControl = {
    let control = UISegmentedControl(items: ["My likes", "Inbox"])
    control.backgroundColor = AppColor.segmented.uiColor.withAlphaComponent(0.1)
    control.layer.cornerRadius = 10
    control.selectedSegmentIndex = 0
    return control
}()

P/S. I know that I am able to do it without segmented control but using buttons.

1 Answers

I think best way to make custom View with buttons. Because this style of segment Control only available in ios 13+.

Related