Skip to content

Commit

Permalink
UI7BorderedRoundedRectButton
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Sep 15, 2013
1 parent 02f2912 commit 03472b4
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 26 deletions.
4 changes: 2 additions & 2 deletions UI7Kit.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "UI7Kit"
s.version = "0.8.25"
s.version = "0.8.26"
s.summary = "UI7Kit is a GUI toolkit to implement iOS7 look & feel UIKit under iOS5/iOS6. It is also supported that patching UIKit to UI7Kit in runtime."
s.homepage = "https://github.com/youknowone/UI7Kit"
s.license = "2-clause BSD"
s.author = { "Jeong YunWon" => "[email protected]" }
s.source = { :git => "https://github.com/youknowone/UI7Kit.git", :tag => "0.8.25" }
s.source = { :git => "https://github.com/youknowone/UI7Kit.git", :tag => "0.8.26" }

s.platform = :ios, '5.0'
s.header_dir = "UI7Kit"
Expand Down
8 changes: 8 additions & 0 deletions UI7Kit/UI7Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@
@property(copy,nonatomic) NSNumber *cornerRadius;

@end


@interface UI7BorderedRoundedRectButton : UI7Button

@property(copy,nonatomic) NSNumber *cornerRadius;
@property(copy,nonatomic) NSNumber *borderWidth;

@end
56 changes: 53 additions & 3 deletions UI7Kit/UI7Button.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
NSDictionary *statefulContents = [aDecoder decodeObjectForKey:@"UIButtonStatefulContent"];
NSObject *normalStatefulContent = statefulContents[@0];
if ([normalStatefulContent.titleColor isEqual:UI7ButtonDefaultTitleColor]) {
[self setTitleColor:nil forState:UIControlStateNormal];
self.___textTitleColor = nil;
} else {
self.___textTitleColor = [self titleColorForState:UIControlStateNormal];
}
}
Expand Down Expand Up @@ -276,3 +273,56 @@ - (void)tintColorDidChange {
}

@end


@implementation UI7BorderedRoundedRectButton

- (void)_roundedRectButtonInit {
self.layer.cornerRadius = self.cornerRadius ? self.cornerRadius.floatValue : 6.0f;
self.layer.borderWidth = self.borderWidth ? self.borderWidth.floatValue : 1.0f;
}

- (void)_tintColorUpdated {
UIColor *tintColor = self.tintColor;
if (tintColor == nil) return;

self.layer.borderColor = tintColor.CGColor;
UIColor *textTitleColor = self.___textTitleColor;
if (tintColor) {
textTitleColor = tintColor;
}
[self __setTitleColor:textTitleColor forState:UIControlStateNormal];
UIColor *highlightedTextTitleColor = textTitleColor.highligtedColor;
[self __setTitleColor:highlightedTextTitleColor forState:UIControlStateHighlighted];
[self __setTitleColor:highlightedTextTitleColor forState:UIControlStateSelected];
}

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
self.___backgroundColor = [aDecoder decodeObjectForKey:@"UIBackgroundColor"];
[self _roundedRectButtonInit];
return self;
}

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
[self _roundedRectButtonInit];
return self;
}

- (void)setBackgroundColor:(UIColor *)backgroundColor {
self.___backgroundColor = backgroundColor;
[self _tintColorUpdated];
}

- (void)setTintColor:(UIColor *)tintColor {
[super setTintColor:tintColor];
[self _tintColorUpdated]; // for iOS6 SDK + iOS7
}

- (void)tintColorDidChange {
[super tintColorDidChange];
[self _tintColorUpdated]; // for iOS7
}

@end
Loading

0 comments on commit 03472b4

Please sign in to comment.