Use CGPath to create rounded rect instead of UIBezierPath

This commit is contained in:
Igor Solomennikov 2026-02-19 12:05:30 -08:00 committed by GitHub
parent d9a171f46b
commit 48484b87fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 18 deletions

View File

@ -44,6 +44,8 @@ public class CVWallpaperBlurView: ManualLayoutViewWithLayer, CVDimmableView {
}
public func applyLayout() {
guard bounds.size.isNonEmpty, maskFrame.size.isNonEmpty else { return }
UIView.performWithoutAnimation {
imageView.frame = imageViewFrame
imageViewMaskLayer.frame = imageView.layer.bounds

View File

@ -145,8 +145,14 @@ public struct BubbleConfiguration {
/// Designed to allow callers to configure masking layers that match bubble shape..
public func bubblePath(for rect: CGRect) -> UIBezierPath {
switch corners.style {
case .uniform(let radius):
return UIBezierPath(roundedRect: rect, cornerRadius: radius)
case .uniform:
let cornerRadius = corners.radius(for: .topLeft, in: rect)
return UIBezierPath(cgPath: CGPath(
roundedRect: rect,
cornerWidth: cornerRadius,
cornerHeight: cornerRadius,
transform: nil,
))
case .segmented(let sharpCorners, let sharpCornerRadius, let wideCornerRadius):
return UIBezierPath.roundedRect(
@ -169,21 +175,6 @@ public struct BubbleConfiguration {
public func strokePath(for rect: CGRect) -> UIBezierPath? {
guard stroke != nil else { return nil }
switch corners.style {
case .uniform(let radius):
return UIBezierPath(roundedRect: rect, cornerRadius: radius)
case .segmented(let sharpCorners, let sharpCornerRadius, let wideCornerRadius):
return UIBezierPath.roundedRect(
rect,
sharpCorners: sharpCorners,
sharpCornerRadius: sharpCornerRadius,
wideCornerRadius: wideCornerRadius,
)
case .capsule:
let cornerRadius = corners.radius(for: .topLeft, in: rect)
return UIBezierPath(roundedRect: rect, cornerRadius: cornerRadius)
}
return bubblePath(for: rect)
}
}