UICornerConfiguration
A configuration that defines how corner radii are mapped to the corners of a rectangle.
Declaration
struct UICornerConfigurationOverview
Create a UICornerConfiguration that expresses how you want the corners of your view to appear. Your configuration can apply to corners independently or uniformly, and can form the following types of corners:
A squared corner
A rounded corner
A rounded corner that’s concentric relative to the containing view
Corners that are rounded to form a capsule
Select a method to create a configuration that describes which corners of your view you want to be uniform and which corners you want to be independent, then provide instances of UICornerRadius as parameters to indicate which type you want each corner to be.
The system uses squared corners by default, so you don’t need to set a configuration to get squared corners.
Configure a rounded corner
To configure a rounded corner with a fixed radius, provide fixed(_:) with a value greater than zero for the radius. Since UICornerRadius conforms to ExpressibleByFloatLiteral and ExpressibleByIntegerLiteral, you can also provide a float or integer value for the radius:
myView.cornerConfiguration = .corners(radius: 12.0)Configure a concentric rounded corner
To configure a rounded corner that’s concentric relative to the containing view, use containerConcentric(minimum:):
myView.cornerConfiguration = .corners(radius: .containerConcentric())Set the minimum parameter to indicate a minimum radius for the rounded corner.
Configure a corner as a capsule
To configure rounded corners that form a capsule, use capsule(maximumRadius:):
myView.cornerConfiguration = .capsule()Set the maximumRadius parameter to allow your view to break the capsule paradigm and stretch vertically with an edge if the radius necessary to form a capsule exceeds what you provide.
Topics
Configuring independent corners
Configuring corners as a capsule
Configuring uniform corners
uniformCorners(radius:)uniformEdges(leftRadius:rightRadius:)uniformEdges(topRadius:bottomRadius:)uniformBottomRadius(_:topLeftRadius:topRightRadius:)uniformLeftRadius(_:topRightRadius:bottomRightRadius:)uniformRightRadius(_:topLeftRadius:bottomLeftRadius:)uniformTopRadius(_:bottomLeftRadius:bottomRightRadius:)