ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - vpeschenkov/LetterAvatarKit: 📲 Use this extension 🧩 to create letter-based avatars or placeholders 🎭 to be utilized within your app
📲 Use this extension 🧩 to create letter-based avatars or placeholders 🎭 to be utilized within your app - vpeschenkov/LetterAvatarKit
Visit Site

GitHub - vpeschenkov/LetterAvatarKit: 📲 Use this extension 🧩 to create letter-based avatars or placeholders 🎭 to be utilized within your app

GitHub - vpeschenkov/LetterAvatarKit: 📲 Use this extension 🧩 to create letter-based avatars or placeholders 🎭 to be utilized within your app

LetterAvatarKit

LetterAvatarKit provides an UIImage extension for generating letter-based avatars/placeholders. There are a few images showing what you can achive by using this framework:

Requirements

  • iOS 8+
  • tvOS 9+
  • Swift 4.0+

Features

  • Easy to use and intuitive interface
  • Highly flexible API allows for customization and integration into various projects
  • Use of the builder pattern for constructing avatar configurations
  • Support for creating circular, square, or bordered images
  • Wide range of flat UI colors available
  • Compatible with tvOS platform

Installation

CocoaPods

LetterAvatarKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LetterAvatarKit", "1.2.5" # Swift 5.0+, Xcode 12
pod "LetterAvatarKit", "1.2.3" # Swift 5.0+, Xcode 11
pod "LetterAvatarKit", "1.1.7" # Swift 4.2
pod "LetterAvatarKit", "1.1.5" # Swift 4.0

Carthage

Add this to Cartfile

github "vpeschenkov/LetterAvatarKit" == 1.2.5 # Swift 5.0+, Xcode 12
github "vpeschenkov/LetterAvatarKit" == 1.2.3 # Swift 5.0+, Xcode 11
github "vpeschenkov/LetterAvatarKit" == 1.1.7 # Swift 4.2
github "vpeschenkov/LetterAvatarKit" == 1.1.5 # Swift 4.0
$ carthage update

Usage

Swift

Using LetterAvatarMaker:

// Square avatar image
let avatarImage = LetterAvatarMaker()
    .setUsername("Letter Avatar")
    .build()
avatarImageView.image = avatarImage

// Circle avatar image with white border
let circleAvatarImage = LetterAvatarMaker()
    .setCircle(true)
    .setUsername("Letter Avatar")
    .setBorderWidth(1.0)
    .setBackgroundColors([ .red ])
    .build()
avatarImageView.image = circleAvatarImage

Using LetterAvatarMaker with closures:

let avatarImage = LetterAvatarMaker()
    .build { c in
        c.username = "Letter Avatar"
    }
avatarImageView.image = avatarImage

let avatarImage = LetterAvatarMaker()
    .build { c in
        c.circle = true
        c.username = "Letter Avatar"
        c.borderWidth = 1.0
        c.backgroundColors = [ .red ]
    }
avatarImageView.image = avatarImage

Using LetterAvatarBuilderConfiguration:

let configuration = LetterAvatarBuilderConfiguration()
configuration.username = "Letter Avatar"
avatarImageView.image = UIImage.makeLetterAvatar(withConfiguration: configuration)

Using UIImage extension:

avatarImageView.image = UIImage.makeLetterAvatar(withUsername: "Letter Avatar")

Objective-C

Using LKLetterAvatarBuilderCongiguration:

LKLetterAvatarBuilderCongiguration *configuration = [[LKLetterAvatarBuilderCongiguration alloc] init];
configuration.username = @"Letter Avatar";
self.avatarImageView.image = [UIImage lk_makeLetterAvatarWithConfiguration:configuration];

Using UIImage extension:

self.avatarImageView.image = [UIImage lk_makeLetterAvatarWithUsername:@"Letter Avatar"];

Customization

You can configure the following properties of LetterAvatarBuilderConfiguration:

/// The username.
open var username: String?
/// The size of an avatar image.
open var size: CGSize = CGSize(width: 80, height: 80)
/// The flag that indicates of using single only one letter, otherwise,
/// as much as wil be possible to obtain. But no more than 3 letters.
open var isSingleLettered: Bool = false
/// The letters font.
open var lettersFont: UIFont = UIFont.systemFont(ofSize: 16.0)
/// The letters colors
open var lettersColor: UIColor = LKUIColorByRGB(red: 236, green: 240, blue: 241)
/// The background colors of an image.
open var backgroundColors: [UIColor] = UIColor.colors
/// The letters font attributes.
open var lettersFontAttributes: [NSAttributedString.Key: Any]?
/// Indicates whether to generate circle or square image.
open var circle: Bool = false
/// The border width of the image.
open var borderWidth: CGFloat = 0.0
/// The border color of the image.
open var borderColor: UIColor = UIColor.white
/// A Boolean flag indicating whether the avatar is opaque.
open var opaque: Bool = false

Community

Questions, comments, issues, and pull requests are welcome!

Contacts

License

Distributed under the MIT license. See LICENSE for more information.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory