This project contains the implementation of an OTP (One-Time Password) screen using plain SwiftUI.
Here's a screenshot of the OTP screen in action:
- SwiftUI-based OTP input screen
- Clean and minimal design
- Easy to integrate into any SwiftUI project
Follow these steps to integrate the OTP screen into your project:
-
Clone the repository:
git clone https://github.com/ShivadityaKr/SwiftUI-OTP.git
-
Open the project in Xcode:
Navigate to the project directory and open the
.xcodeproj
file with Xcode.cd SwiftUI-OTP open SwiftUI-OTP.xcodeproj
-
Build and run:
Select your target device or simulator and press
Cmd + R
to build and run the project.
To use the OTP screen in your own SwiftUI project, follow these steps:
-
Copy the OTP screen files:
Copy the necessary files from this project to your own project. These typically include the SwiftUI view and any related files (such as view models or custom components).
-
Add the OTP screen to your view hierarchy:
Add the OTP screen view to your existing view hierarchy where you need the OTP input functionality.
import SwiftUI struct ContentView: View { @State var otpText = "" var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("OTP Screen") AppOtpView(otpText: $otpText) { value in print(value) } .padding(.top, 10) } .padding() } } #Preview { ContentView() }
-
Customize as needed:
Customize the OTP screen to fit the design and requirements of your application. This may include modifying the appearance, handling different OTP lengths, or integrating with your backend for OTP verification.
- Xcode 12 or later
- iOS 14.0 or later
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any questions or suggestions, feel free to open an issue on the GitHub repository.
By ShivadityaKr