Reputation: 8376
I am trying to create an ASDisplayNode with rounded corners whilst setting its background colour. However, the corners never appear rounded. Why is this? My code:
final class MyNode: ASDisplayNode {
init() {
self.backgroundColor = .red
self.clipsToBounds = true
self.cornerRadius = 10
self.cornerRoundingType = .precomposited
}
...
}
This just creates a rectangle that doesn't have rounded corners...
Upvotes: 1
Views: 376
Reputation: 2922
remove this line
self.cornerRoundingType = .precomposited
I am not really sure how the cornerRoundingType precomposited work too
In the code documentation said
* - ASCornerRoundingTypePrecomposited: corners are drawn using bezier paths to clip the content in a
* CGContext / UIGraphicsContext. This requires .backgroundColor and .cornerRadius to be set. Use opaque
* background colors when possible for optimal efficiency, but transparent colors are supported and much
* more efficient than CALayer. The only limitation of this approach is that it cannot clip children, and
* thus works best for ASImageNodes or containers showing a background around their children.
*
there is someone asking about that in the repo issue too
Upvotes: 1