CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Apr 2016 |
Maintained by Andrea Cipriani.
AGCInitials is an objc UIImageView category to set an image placeholder with the contact's initials and an automatically generated background color.
Import the category
#import "UIImageView+AGCInitials.h"and then call the method with the contact's name:
[_anImageView agc_setImageWithInitialsFromName:@"Mick Jagger"];The image will then contain a placeholder with the initials "MJ" and a generated background color.
- (void)agc_setImageWithInitials:(nonnull NSString*)initials;initialsFromName method for @"Mick Jagger" and @"Michael Jackson" returns MJ as initials, but the background color will be different, because it's generated from the name.@" ", but you can change the separator using:- (void)agc_setImageWithInitialsFromName:(nonnull NSString*)name separatedByString:(nonnull NSString*)separator;NSDictionary* initialsTextAttributes = @{ NSFontAttributeName : [UIFont systemFontOfSize:20], NSForegroundColorAttributeName : [UIColor purpleColor] };
[cellImageView agc_setImageWithInitialsFromName:@"Mick Jagger" separatedByString:@" " withTextAttributes:initialsTextAttributes];#import "AGCInitialsColors.h"And then just set your palette before using the category:
NSArray<UIColor*>* yourColorPalette; //...
[[AGCInitialsColors sharedInstance] setColorPalette:yourColorPalette];To run the example project, clone the repo, and run pod install from the Example directory first.
You can even try the example online with Appetize
Andrea Cipriani, [email protected] - Twitter @AndreaCipriani
UIImageView-AGCInitials is available under the MIT license. See the LICENSE file for more info.