0

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...

Tometoyou
  • 7,792
  • 12
  • 62
  • 108

1 Answers1

0

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

aiwiguna
  • 2,852
  • 2
  • 15
  • 26