Comments (2)
I wanted this same ability, and found it is indeed possible to do so.
After instantiating your instance of CropViewController
, simply set the preferred .modalPresentationStyle
before displaying the controller.
For instance, here is my method that I use to trigger image cropping:
func crop(_ image: UIImage) {
let cropViewController = CropViewController(image: image)
cropViewController.modalPresentationStyle = .currentContext
cropViewController.delegate = self
present(cropViewController, animated: true, completion: nil)
}
With this change, the CropViewController
βwhich is being instantiated by a UIViewController
inside a UIViewControllerRepresentable
β appears contained within a SwiftUI-presented .sheet
, fills that sheet but not the whole screen, and when dismissed that sheet's underlying contents are correctly displayed again, which did not happen with the default full screen presentation style.
Thanks for making all this work, Tim! Love it.
from tocropviewcontroller.
@babbage - I agree this may very well work fine with SwiftUI but I don't use SwiftUI. I use plain Swift for all my programming as of now plus I'm checking this out for a Mac Catalyst app. I noticed that CropViewController
initializes with a modalPresentationStyle
of .overFullScreen
. This is fine and seems to be overridden correctly on iOS devices when I specifiy the presentation style after initializing the CropViewController
.
This doesn't work correctly when running on Mac Catalyst simulation with split view controller (3-column vc). Using .overCurrentContext
for the secondary view controller does not initially position the CropViewController
correctly.
What I did to solve the issue was this in CropViewController
swift file:
...
extension CropViewController {
fileprivate func setUpCropController() {
#if targetEnvironment(macCatalyst)
return
#endif
modalPresentationStyle = .overFullScreen
...
This seems to have solved the Catalyst issue. If Catalyst is runnning there is no need to execute any other setup code in the function as far as I can tell.
Thank you for your suggestions!
from tocropviewcontroller.
Related Issues (20)
- Cropping frame is not resizing
- support free angle!!!
- PackageIndex.findPackages failed: featureDisabled HOT 2
- Please make a release HOT 2
- Cropping conflicts with Stage Manager window resize gesture HOT 1
- Is this project abandoned? HOT 1
- Getting deprecation warnings when compiling for iOS 16. HOT 2
- When the screen is horizontal, it should support the toolbar on the left or right
- How do you match foreground to background? HOT 1
- How to integrate this into my ios sdk HOT 1
- How to remove close button from the toolbar. HOT 1
- Inquiry about Support for Apple's Privacy Manifest Files #2308 HOT 2
- Supports custom subview and public func crop, rotate,... HOT 1
- If you can drag the crop box at will, it is similar to dragging the crop box during scanning
- Privacy Manifest - Missing an expected key: 'NSPrivacyCollectedDataType' HOT 3
- Replace UIGraphicsBeginImageContextWithOptions (Deprecated)
- Privacy Policy causes RN 0.74.1 to not build
- Fail to build HOT 2
- SwiftUI compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tocropviewcontroller.