Skip to content

Commit

Permalink
Neue Inits
Browse files Browse the repository at this point in the history
  • Loading branch information
tonimoeckel committed Jun 13, 2014
1 parent 513a587 commit b4f2bf4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

@interface FABarButtonItem : UIBarButtonItem

-(void) setIcon:(NIKFontAwesomeIcon)icon;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic) NIKFontAwesomeIcon icon;

- (id)initWithIcon:(NIKFontAwesomeIcon)icon style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action;
- (id) initWithFontAwesomeIcon:(NIKFontAwesomeIcon)icon target:(id)target action:(SEL)selector;

@end
59 changes: 41 additions & 18 deletions FontAwesomeIconFactory-Extensions/BarButtonItem/FABarButtonItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,73 @@
#import "FABarButtonItem.h"


@interface FABarButtonItem(){
NIKFontAwesomeIcon _icon;
}
@interface FABarButtonItem()

@end

@implementation FABarButtonItem

- (id)initWithIcon:(NIKFontAwesomeIcon)icon style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action {

self = [super initWithTitle:@"" style:style target:target action:action];
- (void)awakeFromNib
{
[super awakeFromNib];

[self setIcon:self.tag];
}




- (id)initWithFontAwesomeIcon:(NIKFontAwesomeIcon)icon target:(id)target action:(SEL)selector{

self = [super initWithImage:[[self factory] createImageForIcon:icon] style:UIBarButtonItemStylePlain target:target action:selector];

if (self){
[self setIcon:icon];
}

return self;
}

- (id)initWithIcon:(NIKFontAwesomeIcon)icon style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action {

self = [self initWithFontAwesomeIcon:icon target:target action:action];

return self;

}

- (void)awakeFromNib
{
[super awakeFromNib];
- (void)setColor:(UIColor *)color {
_color = color;
[self setIcon:_icon];
}


- (NIKFontAwesomeIconFactory *) factory {
NIKFontAwesomeIconFactory *factory = [NIKFontAwesomeIconFactory barButtonItemIconFactory];
return factory;
}

- (void)setTintColor:(UIColor *)tintColor {

[super setTintColor:tintColor];
[self setIcon:_icon];

[self setIcon:self.tag];
}

- (void)setIcon:(NIKFontAwesomeIcon)icon {
_icon = icon;
NIKFontAwesomeIconFactory *factory = [NIKFontAwesomeIconFactory barButtonItemIconFactory];
if (self.tintColor){
[factory setColors:@[self.tintColor]];

if (self.color){
[factory setColors:@[self.color]];
}else if ([[UINavigationBar appearance] tintColor]){
[factory setColors:@[[[UINavigationBar appearance] tintColor]]];
}

[self setImage:[factory createImageForIcon:icon]];


}

- (void)setTintColor:(UIColor *)tintColor {

[super setTintColor:tintColor];
[self setIcon:_icon];

}

@end
8 changes: 1 addition & 7 deletions FontAwesomeIconFactory-Extensions/Button/FAButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@ - (void)awakeFromNib

- (void)setIcon:(NIKFontAwesomeIcon)icon {
_icon = icon;


NIKFontAwesomeIconFactory *factory = [NIKFontAwesomeIconFactory buttonIconFactory];
[factory setColors:@[self.tintColor]];
[factory setSize:self.bounds.size.height *0.8];
[factory setColors:@[[self titleColorForState:UIControlStateNormal]]];
[self setImage:[factory createImageForIcon:icon] forState:UIControlStateNormal];
[factory setColors:@[[self titleColorForState:UIControlStateSelected]]];
[self setImage:[factory createImageForIcon:icon] forState:UIControlStateSelected];
[factory setColors:@[[self titleColorForState:UIControlStateDisabled]]];
[self setImage:[factory createImageForIcon:icon] forState:UIControlStateDisabled];


}
Expand Down

0 comments on commit b4f2bf4

Please sign in to comment.