Skip to content

Commit 9dfc64b

Browse files
committed
Add iOS 26 liquid glass support to Apple Music alert views
Both AlertAppleMusic16View and AlertAppleMusic17View now auto-upgrade their background to a tinted UIGlassEffect on iOS 26+, falling back to the existing blur material on older versions. A new init parameter lets callers opt out and keep the classic blur on iOS 26.
1 parent e8a0208 commit 9dfc64b

3 files changed

Lines changed: 61 additions & 41 deletions

File tree

README.md

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public enum AlertViewStyle {
4141

4242
- [Installation](#installation)
4343
- [Swift Package Manager](#swift-package-manager)
44-
- [CocoaPods](#cocoapods)
4544
- [SwiftUI](#swiftui)
4645
- [Present & Dismiss](#present--dismiss)
4746
- [Customisation](#customisation)
@@ -56,31 +55,17 @@ Ready to use on iOS 13+. Supports iOS and visionOS. Working with `UIKit` and `Sw
5655
In Xcode go to Project -> Your Project Name -> `Package Dependencies` -> Tap _Plus_. Insert url:
5756

5857
```
59-
https://github.com/sparrowcode/AlertKit
58+
https://github.com/eladdekel/AlertKit
6059
```
6160

6261
or adding it to the `dependencies` of your `Package.swift`:
6362

6463
```swift
6564
dependencies: [
66-
.package(url: "https://github.com/sparrowcode/AlertKit", .upToNextMajor(from: "5.1.8"))
65+
.package(url: "https://github.com/eladdekel/AlertKit", .upToNextMajor(from: "5.1.8"))
6766
]
6867
```
6968

70-
### CocoaPods:
71-
72-
This is an outdated way of doing things. I advise you to use [SPM](#swift-package-manager). However, I will continue to support Cocoapods for some time.
73-
74-
<details><summary>Cocoapods Installation</summary>
75-
76-
[CocoaPods](https://cocoapods.org) is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`:
77-
78-
```ruby
79-
pod 'SPAlert'
80-
```
81-
82-
</details>
83-
8469
### Manually
8570

8671
If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/AlertKit` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.
@@ -109,6 +94,21 @@ alertView.titleLabel.font = UIFont.systemFont(ofSize: 21)
10994
alertView.titleLabel.textColor = .white
11095
```
11196

97+
### Liquid Glass (iOS 26+)
98+
99+
On iOS 26 and later, both `AlertAppleMusic16View` and `AlertAppleMusic17View` automatically upgrade their background to a tinted `UIGlassEffect`. On older iOS versions they fall back to the original blur material, so no caller changes are required.
100+
101+
If you want to opt out and force the classic blur on iOS 26+, pass `forceNonGlass: true` at construction time:
102+
103+
```swift
104+
let alertView = AlertAppleMusic17View(title: "Added to Library", subtitle: nil, icon: .done, forceNonGlass: true)
105+
106+
// also available on the iOS 16 style
107+
let alertView16 = AlertAppleMusic16View(title: "Added to Library", subtitle: nil, icon: .done, forceNonGlass: true)
108+
```
109+
110+
The flag must be set at init — the background effect is built during initialisation, so a property change afterwards would have no effect.
111+
112112
## Present & Dismiss
113113

114114
You can present and dismiss alerts manually via view.
@@ -128,18 +128,6 @@ For dismiss all alerts that was presented:
128128
AlertKitAPI.dismissAllAlerts()
129129
```
130130

131-
## Apps Using
132-
133-
<p float="left">
134-
<a href="https://apps.apple.com/app/id1624477055"><img src="https://cdn.sparrowcode.io/github/apps-using/id1624477055.png?v=2" height="65"></a>
135-
<a href="https://apps.apple.com/app/id1625641322"><img src="https://cdn.sparrowcode.io/github/apps-using/id1625641322.png?v=2" height="65"></a>
136-
<a href="https://apps.apple.com/app/id1625641322"><img src="https://cdn.sparrowcode.io/github/apps-using/id6449774982.png?v=2" height="65"></a>
137-
<a href="https://apps.apple.com/app/id875280793"><img src="https://cdn.sparrowcode.io/github/apps-using/id875280793.png?v=2" height="65"></a>
138-
<a href="https://apps.apple.com/app/id743843090"><img src="https://cdn.sparrowcode.io/github/apps-using/id743843090.png?v=2" height="65"></a>
139-
<a href="https://apps.apple.com/app/id537070378"><img src="https://cdn.sparrowcode.io/github/apps-using/id537070378.png?v=2" height="65"></a>
140-
<a href="https://apps.apple.com/app/id1617055933"><img src="https://cdn.sparrowcode.io/github/apps-using/id1617055933.png?v=2" height="65"></a>
141-
<a href="https://apps.apple.com/app/id1668579869"><img src="https://cdn.sparrowcode.io/github/apps-using/id1668579869.png?v=1" height="65"></a>
142-
<a href="https://apps.apple.com/app/id6451087813"><img src="https://cdn.sparrowcode.io/github/apps-using/id6451087813.png?v=1" height="65"></a>
143-
</p>
131+
## Disclaimer
144132

145-
If you use a `AlertKit`, add your app via Pull Request.
133+
This is a fork of sparrowcode's [AlertKit](https://github.com/sparrowcode/AlertKit) to support iOS 26's tinted glass.

Sources/AlertKit/Views/AlertAppleMusic16View.swift

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class AlertAppleMusic16View: UIView, AlertViewProtocol {
1111
public let titleLabel: UILabel?
1212
public let subtitleLabel: UILabel?
1313
public let iconView: UIView?
14+
15+
private let forceNonGlass: Bool
1416

1517
public static var defaultContentColor = UIColor { trait in
1618
switch trait.userInterfaceStyle {
@@ -26,23 +28,36 @@ public class AlertAppleMusic16View: UIView, AlertViewProtocol {
2628
fileprivate var completion: (()->Void)? = nil
2729

2830
private lazy var backgroundView: UIVisualEffectView = {
29-
let view: UIVisualEffectView = {
31+
let effect: UIVisualEffect = {
3032
#if !os(tvOS)
33+
if #available(iOS 26, *), !forceNonGlass {
34+
let glass = UIGlassEffect()
35+
glass.tintColor = UIColor { trait in
36+
switch trait.userInterfaceStyle {
37+
case .dark: return UIColor.white.withAlphaComponent(0.12)
38+
default: return UIColor.black.withAlphaComponent(0.06)
39+
}
40+
}
41+
return glass
42+
}
3143
if #available(iOS 13.0, *) {
32-
return UIVisualEffectView(effect: UIBlurEffect(style: .systemThickMaterial))
44+
return UIBlurEffect(style: .systemThickMaterial)
3345
} else {
34-
return UIVisualEffectView(effect: UIBlurEffect(style: .light))
46+
return UIBlurEffect(style: .light)
3547
}
3648
#else
37-
return UIVisualEffectView(effect: UIBlurEffect(style: .light))
49+
return UIBlurEffect(style: .light)
3850
#endif
3951
}()
52+
let view = UIVisualEffectView(effect: effect)
4053
view.isUserInteractionEnabled = false
4154
return view
4255
}()
43-
44-
public init(title: String? = nil, subtitle: String? = nil, icon: AlertIcon? = nil) {
45-
56+
57+
public init(title: String? = nil, subtitle: String? = nil, icon: AlertIcon? = nil, forceNonGlass: Bool = false) {
58+
59+
self.forceNonGlass = forceNonGlass
60+
4661
if let title = title {
4762
let label = UILabel()
4863
label.font = UIFont.preferredFont(forTextStyle: .title2, weight: .bold)

Sources/AlertKit/Views/AlertAppleMusic17View.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol, AlertViewInternal
1212
public let titleLabel: UILabel?
1313
public let subtitleLabel: UILabel?
1414
public let iconView: UIView?
15+
16+
private let forceNonGlass: Bool
1517

1618
public static var defaultContentColor = UIColor { trait in
1719
#if os(visionOS)
@@ -38,14 +40,29 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol, AlertViewInternal
3840
hostView.isUserInteractionEnabled = false
3941
return hostView
4042
#else
41-
let view = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
43+
let effect: UIVisualEffect
44+
if #available(iOS 26, *), !forceNonGlass {
45+
let glass = UIGlassEffect()
46+
glass.tintColor = UIColor { trait in
47+
switch trait.userInterfaceStyle {
48+
case .dark: return UIColor.white.withAlphaComponent(0.12)
49+
default: return UIColor.black.withAlphaComponent(0.06)
50+
}
51+
}
52+
effect = glass
53+
} else {
54+
effect = UIBlurEffect(style: .systemMaterial)
55+
}
56+
let view = UIVisualEffectView(effect: effect)
4257
view.isUserInteractionEnabled = false
4358
return view
4459
#endif
4560
}()
4661

47-
public init(title: String? = nil, subtitle: String? = nil, icon: AlertIcon? = nil) {
48-
62+
public init(title: String? = nil, subtitle: String? = nil, icon: AlertIcon? = nil, forceNonGlass: Bool = false) {
63+
64+
self.forceNonGlass = forceNonGlass
65+
4966
if let title = title {
5067
let label = UILabel()
5168
label.font = UIFont.preferredFont(forTextStyle: .body, weight: .semibold, addPoints: -2)

0 commit comments

Comments
 (0)