Skip to main content
Version: Next

OCButton - Custom SwiftUI Button Component

OCButton is a custom SwiftUI button component that enables you to create buttons with various styles and configurations. It supports both text and icon-based buttons, providing flexibility and customization options. This README will guide you through using and integrating the OCButton component into your SwiftUI projects.

Features

  • Create buttons with text, icons, or both.
  • Customize button appearance based on the provided OCButtonType.
  • Control the enabled state of the button.
  • Configure icon alignment within the button.
  • Specify an action closure to be executed when the button is pressed.

Installation

  1. Copy the OCButton struct code from [OCButton.swift] and related Utils and Add it in your project.

Usage

You can create an instance of OCButton by initializing it with various parameters. Here's an example of how to create a button with a title and an icon:

OCButton(
title: "Submit",
type: .primary,
icon: Image(systemName: "checkmark.circle"),
iconAlignment: .leading,
action: { isEnabled in
if isEnabled {
// Handle button press
}
}
)