To run the example project, clone the repo, and run pod install from the Example directory first.
SampleOTP is a Swift library designed to simplify the implementation of One-Time Password (OTP) input fields in iOS applications. It provides a customizable and user-friendly UI model that enhances the user experience during OTP entry.
The SampleOTPViewUIModel struct allows developers to configure various aspects of the OTP input field, including:
- Length: Specify the number of OTP characters.
- Space: Control the spacing between OTP input fields.
- Text Color: Set the color of the entered text.
- Secure Text Entry: Option to mask the entered text for security.
- Placeholder: Define a placeholder string to guide users.
- Font Size: Customize the font size of the OTP input.
- Border Properties: Adjust the border width, color, and corner radius for both active and default states.
- Background Color: Set the background color of the input fields.
- Animations: Choose from various animation styles for enhancing user interaction (e.g., pulse, fadeIn, bounce).
- Typing Styles: Customize the appearance of the input field when active or focused.
To utilize the SampleOTPViewUIModel, initialize it with your desired parameters to create a visually appealing and functional OTP input field.
let otpViewModel = SampleOTPViewUIModel(
length: 6,
space: 10,
textColor: .black,
isSecureTextEntry: true,
placeholder: "*",
fontSize: 16,
borderWidth: 2,
borderColor: .gray,
fieldCornerRadius: 8,
fieldBackgroundColor: .white,
animationOTP: .pulse,
typingOTPStyle: .active,
activeTextColor: .blue,
activeBorderColor: .green,
activeBorderWidth: 3,
activeFieldCornerRadius: 10,
activeFieldBackgroundColor: .lightGray
)SampleOTP is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SampleOTP'Pola Gamal, [email protected]
SampleOTP is available under the MIT license. See the LICENSE file for more info.