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
- Download the SwiftIcons repository or clone it from GitHub.
- Navigate to the downloaded folder and open your project in Xcode.
- Add the contents of the
SwiftIcons
folder to your project. - Make sure to include the necessary frameworks (UIKit and CoreGraphics).
- 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:
- Import the SwiftIcons module:
- Choose an icon set to use. For example, to use FontAwesome, use the following code:
- Display the icon in your app by assigning it to an image view:
- Customize the icon’s appearance by modifying various properties:
import SwiftIcons
let icon = UIImage.init(icon: .fontAwesome(.apple), size: CGSize(width: 50, height: 50))
imageView.image = icon
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.