Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//
// IonIcons+Additions+.h
// Created by Quentin Rousseau on 24/10/14.
// http://quent.in
//
#import <Foundation/Foundation.h>
#import "IonIcons.h"
@interface IonIcons (Additions)
+ (UIButton*) buttonWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
+ (UIButton*) roundedButtonWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
+ (UIImageView*) imageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
+ (UIImageView*) roundedImageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
fillColor:(UIColor*)fillColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
+ (UIImageView*) roundedImageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
@end
//
// IonIcons+Additions+.m
// Created by Quentin Rousseau on 24/10/14.
// http://quent.in
//
#import "IonIcons+Additions.h"
@implementation IonIcons (Additions)
+ (UIButton*) buttonWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize
{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, imageSize.width, imageSize.height)];
UIImage *icon = [IonIcons imageWithIcon:icon_name iconColor:iconColor iconSize:iconSize/1.2f imageSize:imageSize];
[button setBackgroundImage:icon forState:UIControlStateNormal];
return button;
}
+ (UIButton*) roundedButtonWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, imageSize.width, imageSize.height)];
UIImage *icon = [IonIcons imageWithIcon:icon_name iconColor:iconColor iconSize:iconSize / 1.2f imageSize:imageSize];
[button setBackgroundImage:icon forState:UIControlStateNormal];
[button.layer setCornerRadius:imageSize.height / 2.f];
[button.layer setBorderColor:iconColor.CGColor];
[button.layer setBorderWidth:1];
return button;
}
+ (UIImageView*) imageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, imageSize.width, imageSize.height)];
if(icon_name)
{
UIImage *icon = [IonIcons imageWithIcon:icon_name iconColor:iconColor iconSize:iconSize imageSize:imageSize];
[imageView setImage:icon];
}
return imageView;
}
+ (UIImageView*) roundedImageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
{
return [self roundedImageViewWithIcon:icon_name iconColor:iconColor fillColor:[UIColor clearColor] iconSize:iconSize imageSize:imageSize];
}
+ (UIImageView*) roundedImageViewWithIcon:(NSString*)icon_name
iconColor:(UIColor*)iconColor
fillColor:(UIColor*)fillColor
iconSize:(CGFloat)iconSize
imageSize:(CGSize)imageSize;
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, imageSize.width, imageSize.height)];
if(icon_name)
{
UIImage *icon = [IonIcons imageWithIcon:icon_name iconColor:iconColor iconSize:iconSize / 1.2f imageSize:imageSize];
[imageView setImage:icon];
}
[imageView setBackgroundColor:fillColor];
[imageView.layer setCornerRadius:imageSize.height / 2.f];
[imageView.layer setBorderColor:iconColor.CGColor];
[imageView.layer setBorderWidth:1];
return imageView;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment