ScanCodes is a Swift library with scan code features, such as a ScanCode SwiftUI view that can render any string value as a scan code.
ScanCodes extends Image as well as platform-specific image types with scan code-related functionality, and has a ScanCodeType enum that defines all supported scan code types.
ScanCodes can be installed with the Swift Package Manager:
https://github.com/danielsaidi/ScanCodes.git
ScanCodes supports iOS 15, iPadOS 15, macOS 12, tvOS 15, and visionOS 1.
You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
To render a scan code in SwiftUI, just add a ScanCode with the value and type to render:
struct ContentView: View {
var body: some View {
ScanCode(
value: "123456789",
type: .qr,
scale: 5,
rotation: .pi/4
)
}
}You can use the same init arguments to create a SwiftUI SwiftUICore/Image and platform-specific image values.
The online documentation has more information, articles, code examples, etc.
The Demo folder has a demo app that lets you explore the library.
Feel free to reach out if you have questions, or want to contribute in any way:
- Website: danielsaidi.com
- E-mail: daniel.saidi@gmail.com
- Bluesky: @danielsaidi@bsky.social
- Mastodon: @danielsaidi@mastodon.social
ScanCodes is available under the MIT license. See the LICENSE file for more info.
