Skip to content

Instantly share code, notes, and snippets.

@kwent
Last active August 29, 2015 14:08
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kwent/d9ba3f62e62dc4a36df8 to your computer and use it in GitHub Desktop.
//
// 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