How to make rounded borders and stroke for UIButton in Swift?
Hello everyone! I'm a beginner in iOS development and trying to create a beautiful button with rounded corners and a colored stroke. I'm using Swift and Interface Builder, but I can't figure out how to properly configure the button's appearance.
Here's what I'm doing: I create a UIButton in the storyboard, set a white background, blue text, and I want the button to have rounded corners and a blue border with a thickness of 2 pixels. I tried changing properties in the attributes inspector, but there are no sliders for corner radius or border thickness.
I tried to do it programmatically in the viewDidLoad method:
```swift
override func viewDidLoad() {
super.viewDidLoad()
myButton.layer.cornerRadius = 10
myButton.layer.borderWidth = 2
myButton.layer.borderColor = UIColor.blue.cgColor
}
```
But it didn't work — the button
No answers yet.
Log in to leave an answer
Blogs