Question: Before asking the question, I have searched stackoverflow, find a related post:

[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color) 

But we can see it is in `objective-c` language.

So how can we change the borderColor of `UISegmentControl` in `swift` ?

Answer: 
More simple approach:

```
segmentControl.layer.borderWidth = 1.0
segmentControl.layer.cornerRadius = 5.0
segmentControl.layer.borderColor = UIColor.red.cgColor
segmentControl.layer.masksToBounds = true

```
Add the outlet

```
@IBOutlet weak var customSegment: UISegmentedControl!

```

then in your viewDidload method

```
    customSegment.layer.borderWidth = 1.0
    customSegment.layer.cornerRadius = 5.0
    customSegment.layer.borderColor = UIColor.red.cgColor
    customSegment.layer.masksToBounds = true

```

[![enter image description here](https://i.stack.imgur.com/B7UWt.png)](https://i.stack.imgur.com/B7UWt.png)