Cкругления glass iOS 26, фикс compiler crash
This commit is contained in:
@@ -103,6 +103,13 @@ final class _KeyboardSyncedVC<Content: View, Composer: View>: UIViewController,
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError() }
|
||||
|
||||
deinit {
|
||||
// Explicit deinit — workaround for Swift compiler crash in Release
|
||||
// optimization (SILFunctionTransform "EarlyPerfInliner" on deinit).
|
||||
onComposerHeightChange = nil
|
||||
onTopSafeAreaChange = nil
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = .clear
|
||||
|
||||
@@ -108,7 +108,6 @@ final class TelegramGlassUIView: UIView {
|
||||
|
||||
// iOS 26+ native glass
|
||||
private var nativeGlassView: UIVisualEffectView?
|
||||
private var glassMaskLayer: CAShapeLayer?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
@@ -139,6 +138,8 @@ final class TelegramGlassUIView: UIView {
|
||||
let glassView = UIVisualEffectView(effect: effect)
|
||||
glassView.clipsToBounds = true
|
||||
glassView.layer.cornerCurve = .continuous
|
||||
// Set initial corner radius — will be updated in layoutSubviews.
|
||||
glassView.layer.cornerRadius = 22
|
||||
glassView.isUserInteractionEnabled = false
|
||||
addSubview(glassView)
|
||||
nativeGlassView = glassView
|
||||
@@ -200,18 +201,7 @@ final class TelegramGlassUIView: UIView {
|
||||
radius = bounds.height / 2
|
||||
}
|
||||
if #available(iOS 26.0, *), let glassView = nativeGlassView {
|
||||
let mask: CAShapeLayer
|
||||
if let existing = glassMaskLayer {
|
||||
mask = existing
|
||||
} else {
|
||||
mask = CAShapeLayer()
|
||||
glassMaskLayer = mask
|
||||
glassView.layer.mask = mask
|
||||
}
|
||||
mask.path = UIBezierPath(
|
||||
roundedRect: bounds,
|
||||
cornerRadius: radius
|
||||
).cgPath
|
||||
glassView.layer.cornerRadius = radius
|
||||
} else {
|
||||
clippingContainer.cornerRadius = radius
|
||||
layer.cornerRadius = radius
|
||||
@@ -235,20 +225,9 @@ final class TelegramGlassUIView: UIView {
|
||||
|
||||
if #available(iOS 26.0, *), let glassView = nativeGlassView {
|
||||
glassView.frame = bounds
|
||||
// UIGlassEffect ignores layer.cornerRadius changes after initial layout.
|
||||
// Use CAShapeLayer mask — guaranteed to clip the glass to any shape.
|
||||
let mask: CAShapeLayer
|
||||
if let existing = glassMaskLayer {
|
||||
mask = existing
|
||||
} else {
|
||||
mask = CAShapeLayer()
|
||||
glassMaskLayer = mask
|
||||
glassView.layer.mask = mask
|
||||
}
|
||||
mask.path = UIBezierPath(
|
||||
roundedRect: bounds,
|
||||
cornerRadius: cornerRadius
|
||||
).cgPath
|
||||
// Use cornerRadius directly — simpler and works in current iOS 26 betas.
|
||||
// CAShapeLayer mask was unreliable with UIGlassEffect in some beta versions.
|
||||
glassView.layer.cornerRadius = cornerRadius
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -823,3 +823,4 @@ private struct ClassicSwipeActionsModifier: ViewModifier {
|
||||
ChatListView(isSearchActive: .constant(true), isDetailPresented: .constant(false))
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user