PrideChung / FontAwesomeKit

Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons.
MIT License
2.81k stars 308 forks source link

stack icons into a composite image #12

Closed alexshepard closed 10 years ago

alexshepard commented 10 years ago

It would be lovely to be able to stack multiple icons into the same image. Each icon could have a different color, alpha, shape and size, and the resulting image would be a composite of the various icons. In this way, we can create FAKIcons that have varying transparencies within the icon, as well as different colors within the icon. I don't know if others will use this, but I need it for my project! :)

PrideChung commented 10 years ago

Hi, Alex

Thanks for your pull request but stacked icons looks like a rarely used feature to me and I prefer not to merge this pull request. As I stressed before I want to keep FAK tiny because I believe reusable components are better than a giant library try to solve everything,

I recommend that you put your code into a factory object like StackedIconsFactory which inherited from NSObject. If you want to use this feature in multiple projects and want to share to others, you can create your own pod and mark FontAwesomeKit as it's dependency.

alexshepard commented 10 years ago

Hi Pride,

Stacked icons are part of the FontAwesome project that FAK is named after. http://fortawesome.github.io/Font-Awesome/examples/#stacked I'm not sure I understand why an implementation of FontAwesome on iOS wouldn't support them.

If you look at the stacked examples on the FontAwesome project page, how are icons like fa-ban, fa-square, and fa-circle supposed to be useful in FontAwesomeKit if they can't be stacked with other icons?

Best, alex

PrideChung commented 10 years ago

OK I'm convinced that this is an useful feature, but putting stackedImageWithIcons:(NSArray *)icons withSize:(CGSize)imageSize in FAKIcon makes me feel a little bit weird since it doesn't return a FAKIcon instance, and every FAKIcon subclass will have access to it. would it be more appropriate to make an UIImage category, or just make a FAKUtils class?

alexshepard commented 10 years ago

I understand your feeling about this implementation being weird.

FAK is your project, so I would be happy to follow your suggestion and make it whatever way that you'd prefer. :)

Best, alex

lynchseattle commented 9 years ago

@alexshepard - So how does this work? I saw this was merged but can't seem to get it to do anything (note, I'm using Swift).

alexshepard commented 9 years ago

@lynchseattle - Pride transitioned this feature into a UIImage category (which in my opinion looks much nicer than the way I originally coded it).

In objective-c:

FAKIcon *pinBG = [FAKIonIcons iosLocationIconWithSize:25];
[pinBG addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor]];
FAKIcon *pinFG = [FAKIonIcons iosLocationOutlineIconWithSize:25];
[pinFG addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor]];
 UIImage *pinStacked = [UIImage imageWithStackedIcons:@[pinBG, pinFG] imageSize:CGSizeMake(25, 25)];