Last active
August 29, 2015 14:08
-
-
Save kwent/d9ba3f62e62dc4a36df8 to your computer and use it in GitHub Desktop.
ionicons-iOS category. Read more at : http://blog.quent.in/blog/2014/10/25/level-up-ionicons-ios-with-a-category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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