Welcome to ThatCamThing! A lightweight, powerful, and easy-to-use camera library for SwiftUI. This package provides a simple way to integrate a custom camera interface into your iOS app, with built-in controls and extensive customization options.
- Simple SwiftUI Integration: A
CameraViewthat works seamlessly within your SwiftUI layouts. - Customizable Overlays: Replace the default camera UI with your own custom SwiftUI view.
- Custom Error Screens: Provide a custom view to display when camera errors occur.
- Full Camera Control: Programmatically manage flash, camera position (front/back), lens type (wide/ultra-wide), zoom, and frame rate.
- Image Capture: A simple closure-based callback to receive captured
UIImageobjects. - Default UI Included: Comes with a sleek, modern, and ready-to-use
DefaultCameraOverlay.
- iOS 15.0+
- Swift 5.5+
- Xcode 13.0+
You can add ThatCamThing to your Xcode project using the Swift Package Manager.
- In Xcode, open your project and navigate to File > Add Packages...
- The Swift Package Manager dialog will appear.
- In the search bar, enter the repository URL:
https://github.com/your-username/CamaragePackageV2.git(Please replace with your actual repository URL). - Choose the version you want to use and click Add Package.
- Select the
ThatCamThinglibrary to be added to your app target.
Integrating ThatCamThing into your SwiftUI view takes just a few steps.
import ThatCamThingIn your Info.plist, add:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera for capturing photos.</string>The library provides default overlay and error views to get started quickly:
CameraView()
.setOverlayScreen(DefaultCameraOverlay.init)
.setErrorScreen(DefaultCameraErrorView.init)To customize the camera behavior, you can configure CameraManagerAttributes:
CameraView()
.setOverlayScreen(DefaultCameraOverlay.init)
.setErrorScreen(DefaultCameraErrorView.init)
.setAttributes(CameraManagerAttributes(
cameraPosition: .back,
frameRate: 60,
flashMode: .auto,
resolution: .hd4K3840x2160,
lensType: .wide
))
.onImageCaptured { image in
// Handle captured UIImage
}You can customize the UI by providing your own views:
To use your own camera overlay, conform to the CameraOverlay protocol:
struct MyOverlay: CameraOverlay {
}To display a custom error view, conform to the CameraErrorOverlay protocol:
struct MyErrorView: CameraErrorOverlay {
}Then apply them like this:
CameraView()
.setOverlayScreen(MyOverlay.init)
.setErrorScreen(MyErrorView.init)