Skip to content

Commit ac3a526

Browse files
committed
Update README for closeButtonAlignment
1 parent b33ce6b commit ac3a526

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ struct ContentView: View {
6767

6868
### Close Button Position
6969

70-
#### Availability: 2.2.0 or higher
70+
#### Availability: 3.0.0 or higher
71+
*Optional:* Defaults to .topLeft
7172

72-
The close button can be moved to the top right if desired. The `closeButtonTopRight` parameter accepts `bool`.
73+
The close button position can be customized. The `closeButtonAlignment` parameter is an enum that accepts `.topLeft`, `.topRight`, `.bottomLeft`, `.bottomRight`, and `.hidden`.
7374

7475
Example:
7576
```Swift
@@ -84,7 +85,7 @@ struct ContentView: View {
8485
Text("Example!")
8586
}
8687
.frame(maxWidth: .infinity, maxHeight: .infinity)
87-
.overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, closeButtonTopRight: true))
88+
.overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, closeButtonAlignment: .topLeft))
8889
}
8990
}
9091
```
@@ -93,6 +94,7 @@ struct ContentView: View {
9394
### Caption
9495

9596
#### Availability: 2.1.0 or higher
97+
*Optional*
9698

9799
A caption can be added to the image viewer. The caption will appear near the bottom of the image viewer (if the image fills the whole screen the text will appear on top of the image). The `caption` parameter accepts `Text`.
98100

@@ -187,6 +189,31 @@ struct ContentView: View {
187189
}
188190
}
189191
```
192+
193+
### Close Button Position
194+
195+
#### Availability: Below 3.0.0
196+
#### *DEPRECATED*: View new usage above for >= 3.0.0
197+
198+
The close button can be moved to the top right if desired. The `closeButtonTopRight` parameter accepts `bool`.
199+
200+
Example:
201+
```Swift
202+
import ImageViewer
203+
204+
struct ContentView: View {
205+
@State var showImageViewer: Bool = true
206+
@State var image = Image("example-image")
207+
208+
var body: some View {
209+
VStack {
210+
Text("Example!")
211+
}
212+
.frame(maxWidth: .infinity, maxHeight: .infinity)
213+
.overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, closeButtonTopRight: true))
214+
}
215+
}
216+
```
190217
</details>
191218

192219
# Compatibility

0 commit comments

Comments
 (0)