How can I create a UIButton with rounded corners that are smooth? The standard apple rounded corners are much nicer than the standard rounded corners. If I design a button in sketch, I can toggle "smooth corners" which toggles the corners of a shape from Apple rounded corners (smooth) to standard rounded corners.
Here is a comparison:
How can I toggle this in swift?
showContentButton.layer.cornerRadius = 20
rounds the corners, however, I don't really know if this rounded corners are "smooth corners" or "standard rounded corners". And I don't know how to toggle this. Any ideas?
Click the icon to adjust each individual corner. Click to open the Corner Smoothing setting. Drag the slider right to increase and left to decrease. Click iOS to set Corner Smoothing to 60%, the default for iOS.
Discussion. Setting the radius to a value greater than 0. 0 causes the layer to begin drawing rounded corners on its background. By default, the corner radius does not apply to the image in the layer's contents property; it applies only to the background color and border of the layer.
Starting iOS 13.0, you can just use this property in addition to setting the cornerRadius:
sampleButton.layer.cornerCurve = .continuous
This is also easily animatable, which previously resulted in problems using a UIBezierPath.
See more at https://developer.apple.com/documentation/quartzcore/calayer/3152596-cornercurve
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With