An extension that generates letter-based avatars.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LetterAvatarKit.xcodeproj Update the project structure Jul 20, 2018
LetterAvatarKit Crash: Fatal error: cannot increment beyond endIndex (#12) Aug 2, 2018
LetterAvatarKitExample Bump version to 1.1.3 Jul 14, 2018
LetterAvatarKitObjcExample Bump version to 1.1.3 Jul 14, 2018
LetterAvatarKitTests
docs Fix some code style issues Jul 21, 2018
fastlane Configure fastlane Jan 26, 2018
scripts Generate docs by jazzy Jul 20, 2018
.gitignore Initial commit Oct 4, 2017
.swift-version Update .swift-version Jul 20, 2018
.swiftlint.yml Configure fastlane Jan 26, 2018
.travis.yml Configure fastlane Jan 26, 2018
CHANGELOG.md Upload LetterAvatarKit to GitHub Oct 11, 2017
CODE_OF_CONDUCT.md Upload LetterAvatarKit to GitHub Oct 11, 2017
Gemfile Configure fastlane Jan 26, 2018
LICENSE Initial commit Oct 4, 2017
LetterAvatarKit.podspec Bump version to 1.1.5 Aug 2, 2018
README.md Generate docs by jazzy Jul 20, 2018

README.md

LetterAvatarKit

LetterAvatarKit is an UIImage extension that generates letter-based avatars. Here are some images showing what LetterAvatarKit does:

Requirements

  • iOS 8 and later
  • Swift 4.0 and later

Installation

CocoaPods

To install LetterAvatarKit using CocoaPods, add this line to your Podfile:

pod "LetterAvatarKit", "1.1.4"

Usage

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

Swift

Using a configuration:

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

or

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

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

Community

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

Contacts

License

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