Skip to content

📦 An extension that generates letter-based avatars

License

Notifications You must be signed in to change notification settings

divyeshmakwana96/LetterAvatarKit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LetterAvatarKit

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

Requirements

  • iOS 8 and later
  • Swift 4.0 and later

Installation

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

pod "LetterAvatarKit", "1.1.8" # Swift 5.0
pod "LetterAvatarKit", "1.1.7" # Swift 4.2
pod "LetterAvatarKit", "1.1.5" # Swift 4.0

Add this to Cartfile

github "vpeschenkov/LetterAvatarKit" == 1.1.8 # Swift 5.0
github "vpeschenkov/LetterAvatarKit" == 1.1.7 # Swift 4.2
github "vpeschenkov/LetterAvatarKit" == 1.1.5 # Swift 4.0
$ carthage update

Usage

Swift

By LetterAvatarBuilderConfiguration:

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

or simplier without the one:

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

Objective-C

Using a configuration:

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

or simplier without the one:

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

Customization

You can configure the following properties of LetterAvatarBuilderConfiguration:

/// The size of an avatar image.
open var size: CGSize = CGSize(width: 80, height: 80)
/// The username.
open var username: String?
/// The flag that indicates of using single letter instead of two lettters.
open var singleLetter: Bool = false
/// The letters font.
open var lettersFont: UIFont = UIFont.systemFont(ofSize: 16.0)
/// The letters colors
open var lettersColor: UIColor = LAKUIColorByRGB(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]?

Community

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

Contacts

License

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

About

📦 An extension that generates letter-based avatars

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 79.5%
  • Objective-C 16.6%
  • Ruby 3.3%
  • Shell 0.6%