Skip to content

Commit 89e34ad

Browse files
committed
Update README.md
1 parent f5d3e8e commit 89e34ad

File tree

1 file changed

+55
-22
lines changed

1 file changed

+55
-22
lines changed

README.md

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Swift](https://img.shields.io/badge/Swift-5.9+-orange.svg)](https://swift.org)
88
[![License](https://img.shields.io/github/license/efremidze/VisualEffectView.svg)](https://github.com/efremidze/VisualEffectView/blob/master/LICENSE)
99

10-
**VisualEffectView** is a blur effect library with tint color support. This library uses the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) to generate the blur.
10+
**VisualEffectView** is a dynamic blur effect library with tint color support and iOS 26+ glass effects. This library uses [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) to generate the blur.
1111

1212
<img src="/Images/demo.gif" width="250" />
1313

@@ -23,25 +23,53 @@ $ pod try VisualEffectView
2323

2424
## Usage
2525

26-
Add an instance of VisualEffectView to your view.
26+
### UIKit
2727

2828
```swift
2929
import VisualEffectView
3030

3131
let visualEffectView = VisualEffectView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
3232

33-
// Configure the view with tint color, blur radius, etc
34-
visualEffectView.colorTint = .redColor()
33+
// Customize the blur
34+
visualEffectView.colorTint = .red
3535
visualEffectView.colorTintAlpha = 0.2
3636
visualEffectView.blurRadius = 10
3737
visualEffectView.scale = 1
3838

3939
addSubview(visualEffectView)
4040
```
4141

42-
Depending on the desired effect, the effect may affect content layered behind the view or content added to the visual effect view’s contentView. After you add the visual effect view to the view hierarchy, add any subviews to the contentView property of the visual effect view. Do not add subviews directly to the visual effect view itself. Refer to the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) for more info.
42+
You can also use different styles:
4343

44-
For more examples, take a look at the example project.
44+
```swift
45+
// System blur
46+
visualEffectView.style = .systemBlur(.dark)
47+
48+
// Glass effect (iOS 26+)
49+
visualEffectView.style = .glass(.regular)
50+
51+
// Custom blur (default)
52+
visualEffectView.style = .customBlur
53+
```
54+
55+
### SwiftUI
56+
57+
```swift
58+
import VisualEffectView
59+
60+
struct ContentView: View {
61+
var body: some View {
62+
VisualEffect(colorTint: .white, colorTintAlpha: 0.5, blurRadius: 18, scale: 1)
63+
}
64+
}
65+
```
66+
67+
Or use the style-based API:
68+
69+
```swift
70+
VisualEffect(style: .glass(.regular))
71+
VisualEffect(style: .systemBlur(.dark))
72+
```
4573

4674
### Customization
4775

@@ -53,28 +81,23 @@ var scale: CGFloat // scale factor. default is 1
5381
var saturation: CGFloat // saturation factor. default is 1
5482
```
5583

56-
If you want `colorTintAlpha` to be different from `0`, make sure you always set it right after setting the `colorTint` or it may not be applied as expected.
57-
You also have to make sure you don't set `colorTintAlpha` if `colorTint` is `nil`.
84+
**Note:** Custom blur properties only work when `style` is `.customBlur`.
5885

59-
### Storyboard Support
60-
61-
Works great with storyboards and xibs.
86+
If you want `colorTintAlpha` to be different from `0`, make sure you always set it right after setting the `colorTint` or it may not be applied as expected. Don't set `colorTintAlpha` if `colorTint` is `nil`.
6287

63-
### SwiftUI Support
88+
### Content View
6489

65-
VisualEffectView supports SwiftUI.
90+
Add subviews to the `contentView` property, not directly to the visual effect view:
6691

6792
```swift
68-
import VisualEffectView
69-
70-
struct ContentView: View {
71-
var body: some View {
72-
VisualEffect(colorTint: .white, colorTintAlpha: 0.5, blurRadius: 10, scale: 1)
73-
}
74-
}
93+
visualEffectView.contentView.addSubview(label)
7594
```
7695

77-
Make sure that `colorTintAlpha` is not set when `colorTint` is `nil`.
96+
Refer to the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) documentation for more info.
97+
98+
### Storyboard Support
99+
100+
Works great with storyboards and xibs.
78101

79102
## Installation
80103

@@ -91,8 +114,16 @@ To install with [Carthage](https://github.com/Carthage/Carthage), simply add thi
91114
github "efremidze/VisualEffectView"
92115
```
93116

117+
### Swift Package Manager
118+
Add VisualEffectView as a dependency in your `Package.swift` file:
119+
```swift
120+
dependencies: [
121+
.package(url: "https://github.com/efremidze/VisualEffectView.git", from: "5.0.0")
122+
]
123+
```
124+
94125
### Manually
95-
1. Download and drop ```VisualEffectView.swift``` in your project.
126+
1. Download and drop the source files in your project.
96127
2. Congratulations!
97128

98129
## Communication
@@ -105,6 +136,8 @@ github "efremidze/VisualEffectView"
105136

106137
VisualEffectView utilizes a private UIKit API to do its magic. Use caution, submitting this code to the App Store adds the risk of being rejected!
107138

139+
The `.systemBlur()` and `.glass()` styles use only public APIs and are safe for App Store submission.
140+
108141
## Credits
109142

110143
https://github.com/collinhundley/APCustomBlurView

0 commit comments

Comments
 (0)