TORoundedButton

Introduction

Welcome to TORoundedButton, a versatile and customizable library for iOS developers to create rounded buttons with ease.

Features

  • Create aesthetically pleasing rounded buttons
  • Customize button appearance
  • Add button icons and control their position
  • Flexible button sizes and shapes
  • Control button border width and color
  • Change button text and label color
  • Support for automatic compatibility with Dark Mode
  • Tap and long press events with target and action support
  • Dynamic font sizing

Installation

To use TORoundedButton in your iOS project, follow these steps:

  1. Open your Xcode project
  2. Navigate to your project directory in Terminal
  3. Run the following command to install TORoundedButton via CocoaPods:

pod 'TORoundedButton'

Usage

Follow these steps to configure and use TORoundedButton:

Step 1: Import

In the relevant file where you want to use TORoundedButton, import the library:

import TORoundedButton

Step 2: Create a button instance

Create an instance of a TORoundedButton:

let roundedButton = TORoundedButton()

Step 3: Customize button appearance

Customize the appearance of the button using available properties:


roundedButton.backgroundColor = .blue
roundedButton.cornerRadius = 10.0
roundedButton.borderWidth = 2.0
roundedButton.borderColor = .white
roundedButton.titleColor = .white

Step 4: Add button icons

To include an icon in the button, set the icon image and choose the desired position:


roundedButton.setIcon(UIImage(named: "your_icon"), for: .normal)
roundedButton.iconPosition = .left

Step 5: Set button size

You can use auto layout or set the button size programmatically:


roundedButton.frame = CGRect(x: 0, y: 0, width: 150, height: 50)

Step 6: Handle tap events

Implement target and action methods to handle button tap events:


roundedButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)

@objc func buttonTapped() {
// Handle button tap event
}

Step 7: Add button to view

Add the button as a subview to your desired view:


yourView.addSubview(roundedButton)

Conclusion

Congratulations! You have successfully learned how to use the TORoundedButton library to create and customize rounded buttons in your iOS app. Enjoy the seamless and attractive user interface it brings to your application.