diff options
author | Ben <31181527+benedom@users.noreply.github.com> | 2024-05-06 14:24:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-06 14:24:50 +0200 |
commit | c959eb9e5cbc8c396af2831ec31295c97c16e6a2 (patch) | |
tree | 2595c6d6951b0c4d3e47fda2023b5dba0a7b5d16 /Demo/SwiftyCropDemo/ContentView.swift | |
parent | edcad92cad74b7dddbad3edf3a5f6709884f2956 (diff) | |
parent | 2a996b8ab52421c8b56a511cb8db5832aea20d41 (diff) |
Merge pull request #8 from cvb941/master
Cap mask radius to image size
Diffstat (limited to 'Demo/SwiftyCropDemo/ContentView.swift')
-rw-r--r-- | Demo/SwiftyCropDemo/ContentView.swift | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Demo/SwiftyCropDemo/ContentView.swift b/Demo/SwiftyCropDemo/ContentView.swift index f4e90ee..f4081a2 100644 --- a/Demo/SwiftyCropDemo/ContentView.swift +++ b/Demo/SwiftyCropDemo/ContentView.swift @@ -82,7 +82,7 @@ struct ContentView: View { .frame(maxWidth: .infinity, alignment: .leading) Button { - maskRadius = UIScreen.main.bounds.width / 2 + maskRadius = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) / 2 } label: { Image(systemName: "arrow.up.left.and.arrow.down.right") .font(.footnote) @@ -135,7 +135,9 @@ struct ContentView: View { // Example function for downloading an image private func downloadExampleImage() async -> UIImage? { - let urlString = "https://picsum.photos/1000/1200" + let portraitUrlString = "https://picsum.photos/1000/1200" + let landscapeUrlString = "https://picsum.photos/2000/1000" + let urlString = Int.random(in: 0...1) == 0 ? portraitUrlString : landscapeUrlString guard let url = URL(string: urlString), let (data, _) = try? await URLSession.shared.data(from: url), let image = UIImage(data: data) |