-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
2,191 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ Pod::Spec.new do |s| | |
s.description = <<-DESC | ||
DESC | ||
s.homepage = "http://EXAMPLE/NAME" | ||
s.homepage = "https://github.com/fmscode/BorderButton" | ||
s.license = 'MIT' | ||
s.author = { "Frank Michael Sanchez" => "[email protected]" } | ||
s.source = { :git => "http://EXAMPLE/NAME.git", :tag => s.version.to_s } | ||
s.source = { :git => "https://github.com/fmscode/BorderButton.git", :tag => s.version.to_s } | ||
|
||
s.platform = :ios, '7.0' | ||
s.requires_arc = true | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// BorderButton.h | ||
// Pods | ||
// | ||
// Created by Frank Michael on 4/10/14. | ||
// | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BorderButton : UIButton | ||
|
||
@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// BorderButton.m | ||
// Pods | ||
// | ||
// Created by Frank Michael on 4/10/14. | ||
// | ||
// | ||
|
||
#import "BorderButton.h" | ||
|
||
@interface BorderButton () { | ||
CAShapeLayer *circleLayer; | ||
UIColor *borderColor; | ||
} | ||
- (void)setupButton; | ||
@end | ||
|
||
@implementation BorderButton | ||
|
||
- (id)initWithFrame:(CGRect)frame | ||
{ | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
// Initialization code | ||
[self setupButton]; | ||
} | ||
return self; | ||
} | ||
- (id)initWithCoder:(NSCoder *)aDecoder{ | ||
self = [super initWithCoder:aDecoder]; | ||
if (self){ | ||
[self setupButton]; | ||
} | ||
return self; | ||
} | ||
- (void)setupButton{ | ||
borderColor = self.titleLabel.textColor; | ||
circleLayer = [CAShapeLayer layer]; | ||
circleLayer.bounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); | ||
circleLayer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); | ||
UIBezierPath *path; | ||
if (self.frame.size.width == self.frame.size.height){ | ||
path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))]; | ||
}else { | ||
path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:8]; | ||
} | ||
circleLayer.path = path.CGPath; | ||
path = nil; | ||
circleLayer.strokeColor = borderColor.CGColor; | ||
circleLayer.lineWidth = 2.0f; | ||
circleLayer.fillColor = nil; | ||
[[self layer] insertSublayer:circleLayer below:self.titleLabel.layer]; | ||
} | ||
- (void)setHighlighted:(BOOL)highlighted{ | ||
if (highlighted){ | ||
circleLayer.fillColor = borderColor.CGColor; | ||
self.titleLabel.textColor = [UIColor whiteColor]; | ||
}else{ | ||
self.titleLabel.textColor = borderColor; | ||
circleLayer.fillColor = nil; | ||
} | ||
} | ||
/* | ||
// Only override drawRect: if you perform custom drawing. | ||
// An empty implementation adversely affects performance during animation. | ||
- (void)drawRect:(CGRect)rect | ||
{ | ||
// Drawing code | ||
} | ||
*/ | ||
|
||
@end |
Oops, something went wrong.