swifticons

Introduction

Welcome to the documentation for SwiftIcons, a lightweight library that provides you with a wide range of free customizable icon sets for your iOS applications. With SwiftIcons, you can easily add stunning icons to your app using pre-defined icons or your own custom icons.

Features

  • Easy to Use: SwiftIcons offers a simple and intuitive way to integrate icons into your iOS app.
  • Customizable: Modify the size, color, and style of icons to match your app’s design and theme.
  • Extensive Icon Library: SwiftIcons provides a vast collection of popular icon sets, including FontAwesome, Ionicons, and more.
  • Custom Icon Support: Easily use your own custom icons by importing them into your project.
  • Well-documented: The library comes with detailed documentation and code examples to assist you in adding icons to your app.

Installation

iOS

To install SwiftIcons in your iOS project, you can use either CocoaPods or manually add the library to your project.

CocoaPods Installation

To install using CocoaPods, add the following line to your Podfile:

pod 'SwiftIcons'

Tip: Don’t forget to run pod install after updating your Podfile, and use the .xcworkspace file to open your project.

Manual Installation

  1. Download the SwiftIcons repository or clone it from GitHub.
  2. Navigate to the downloaded folder and open your project in Xcode.
  3. Add the contents of the SwiftIcons folder to your project.
  4. Make sure to include the necessary frameworks (UIKit and CoreGraphics).
  5. You’re ready to start using SwiftIcons in your app!

Getting Started

Once you have successfully installed SwiftIcons, follow the steps below to quickly integrate and use icons in your iOS app:

  1. Import the SwiftIcons module:
  2. import SwiftIcons
  3. Choose an icon set to use. For example, to use FontAwesome, use the following code:
  4. let icon = UIImage.init(icon: .fontAwesome(.apple), size: CGSize(width: 50, height: 50))
  5. Display the icon in your app by assigning it to an image view:
  6. imageView.image = icon
  7. Customize the icon’s appearance by modifying various properties:
  8. icon.iconColor = .red
    icon.iconTintColor = .white
    icon.backgroundColor = .blue
    icon.cornerRadius = 5
    icon.borderWidth = 2
    icon.borderColor = .black

Usage Examples

Here are a few usage examples to demonstrate how to utilize SwiftIcons in your iOS app:

Example 1 – Using Pre-defined Icon Sets

// Import SwiftIcons module
import SwiftIcons

// Create an image view
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

// Set an icon from FontAwesome icon set
imageView.image = UIImage.init(icon: .fontAwesome(.heart), size: CGSize(width: 100, height: 100))

// Customize the icon's appearance
imageView.tintColor = .red

// Add the image view to your view hierarchy
view.addSubview(imageView)

Example 2 – Using Custom Icons

// Import SwiftIcons module
import SwiftIcons

// Create an image view
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

// Set a custom icon
imageView.image = UIImage.init(icon: .custom("customIconName"), size: CGSize(width: 100, height: 100))

// Customize the icon's appearance
imageView.tintColor = .blue

// Add the image view to your view hierarchy
view.addSubview(imageView)

Example 3 – Customizing Icon Properties

// Import SwiftIcons module
import SwiftIcons

// Create an image view
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

// Set an icon from FontAwesome icon set
imageView.image = UIImage.init(icon: .fontAwesome(.star), size: CGSize(width: 100, height: 100))

// Customize the icon's appearance
imageView.tintColor = .green
imageView.backgroundColor = .yellow
imageView.layer.cornerRadius = 10
imageView.layer.borderWidth = 2
imageView.layer.borderColor = UIColor.black.cgColor

// Add the image view to your view hierarchy
view.addSubview(imageView)

Conclusion

Congratulations! You’ve learned how to integrate SwiftIcons into your iOS app and use customizable icons in just a few simple steps. Enjoy adding beautiful icons to enhance the visual experience of your app.