https://github.com/totocaster/cdfinitialsavatar
Simple to use initials avatar generator for iOS. Highly customizable, but with sane defaults. Works great as a avatar placeholder and such.
https://github.com/totocaster/cdfinitialsavatar
avatar avatar-generator avatar-placeholder initials-avatar sane-defaults
Last synced: 6 months ago
JSON representation
Simple to use initials avatar generator for iOS. Highly customizable, but with sane defaults. Works great as a avatar placeholder and such.
- Host: GitHub
- URL: https://github.com/totocaster/cdfinitialsavatar
- Owner: totocaster
- License: mit
- Created: 2015-03-01T01:16:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-29T09:07:26.000Z (over 8 years ago)
- Last Synced: 2024-03-14T15:48:52.663Z (over 1 year ago)
- Topics: avatar, avatar-generator, avatar-placeholder, initials-avatar, sane-defaults
- Language: Objective-C
- Homepage:
- Size: 24.4 KB
- Stars: 89
- Watchers: 4
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CDFInitialsAvatar
Simple to use initials avatar generator for iOS. Highly customizable, but with sane defaults. Works great as a avatar placeholder till network image is loaded or as an actual image if user has no avatar at all.

## Usage
Defaults mimic look of Apple's own implementation of initial avatars, found in Contact.app and Messages.app on iPhone or OS X. Usage can be as simple those two lines:
```objc
CDFInitialsAvatar *initialsAvatar = [[CDFInitialsAvatar alloc] initWithRect: imageView.bounds fullName:@"Toto Tvalavadze"];
imageView.image = initialsAvatar.imageRepresentation; // actual drawing happens here
```### Further Customizations
You can change `backgroundColor`, `initialsFont` and `initialsColor`. This should cover everything. For details, refer to header file. It's well documented.
Example project also contains usage samples.
### What About Circle Avatars?
I believe generator should be responsible for content only, thus in case you want to mask content with circle (or pretty much any shape), please consider `mask` layer of your `UIImageView`.
See example project to view actual sample.
## Caching
`CDFInitialsAvatar` **does not** cache images it generates. Consider implementing your choice of image caching strategy when using it inside a cell views or in similar cases. In short, treat `imageView.image = initialsAvatar.imageRepresentation` as a very expensive call (which it is).
## Rendering
Actual drawing happens when `imageRepresentation` is called and obviously, is expensive. Consider using it wisely and wrapping it with your choice of caching strategy if needed.
No drawing or/and calculations happen on `initWith...`.
## License
MIT. Included in source files.