Skip to content

Commit

Permalink
Project creation and setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmscode committed Apr 10, 2014
1 parent 074b398 commit 3ede736
Show file tree
Hide file tree
Showing 36 changed files with 2,191 additions and 33 deletions.
4 changes: 2 additions & 2 deletions BorderButton.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Classes/BorderButton.h
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
72 changes: 72 additions & 0 deletions Classes/BorderButton.m
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
Loading

0 comments on commit 3ede736

Please sign in to comment.