I know how to round both sides of a UIButton with: myButton.layer.cornerRadius = 10, but I am not sure how to round just one side so it would look something like this:
I don’t think you can do it in IB, the usual way to do it would be to either set properties or manually via the User Defined Runtime Attributes.
However, setting the a corner radius but only for certain corners requires setting the layer maskedCorners array with values ([.layerMinXMinYCorner, .layerMinXMaxYCorner]) and that is not supported in IB.
The other option would be to write a subclass of UIButton that sets those values in the init method (particularly the init(coder:)) and then change in IB to use that class for the view.
2
Answers
I don’t think you can do it in IB, the usual way to do it would be to either set properties or manually via the User Defined Runtime Attributes.
However, setting the a corner radius but only for certain corners requires setting the layer maskedCorners array with values ([.layerMinXMinYCorner, .layerMinXMaxYCorner]) and that is not supported in IB.
The other option would be to write a subclass of UIButton that sets those values in the init method (particularly the init(coder:)) and then change in IB to use that class for the view.
Use this extension into your project
to call roundCorners Method
Reference
If you need to use extension for all view components
Change
extension UIButton
toextension UIView