Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
Updated attribute names.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbergeron committed Jan 17, 2014
1 parent 6771d62 commit 58a83e7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions BDBAttributedButton/BDBAttributedButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
@import UIKit;


FOUNDATION_EXPORT NSString * const BDBAttributedButtonCornerRadiusName;
FOUNDATION_EXPORT NSString * const BDBAttributedButtonFillColorName;
FOUNDATION_EXPORT NSString * const BDBAttributedButtonBorderColorName;
FOUNDATION_EXPORT NSString * const BDBAttributedButtonBorderWidthName;
FOUNDATION_EXPORT NSString * const BDBCornerRadiusAttributeName;
FOUNDATION_EXPORT NSString * const BDBFillColorAttributeName;
FOUNDATION_EXPORT NSString * const BDBBorderColorAttributeName;
FOUNDATION_EXPORT NSString * const BDBBorderWidthAttributeName;


#pragma mark -
Expand Down
16 changes: 8 additions & 8 deletions BDBAttributedButton/BDBAttributedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#import "BDBAttributedButton.h"


NSString * const BDBAttributedButtonCornerRadiusName = @"com.bradbergeron.BDBAttributedButtonCornerRadiusName";
NSString * const BDBAttributedButtonFillColorName = @"com.bradbergeron.BDBAttributedButtonFillColorName";
NSString * const BDBAttributedButtonBorderColorName = @"com.bradbergeron.BDBAttributedButtonBorderColorName";
NSString * const BDBAttributedButtonBorderWidthName = @"com.bradbergeron.BDBAttributedButtonBorderWidthName";
NSString * const BDBCornerRadiusAttributeName = @"com.bradbergeron.BDBCornerRadiusAttributeName";
NSString * const BDBFillColorAttributeName = @"com.bradbergeron.BDBFillColorAttributeName";
NSString * const BDBBorderColorAttributeName = @"com.bradbergeron.BDBBorderColorAttributeName";
NSString * const BDBBorderWidthAttributeName = @"com.bradbergeron.BDBBorderWidthAttributeName";


#pragma mark -
Expand Down Expand Up @@ -99,17 +99,17 @@ - (UIImage *)BDBAttributedButton_backgroundImageForState:(UIControlState)state
if (!attributes)
return nil;

CGFloat radius = [attributes[BDBAttributedButtonCornerRadiusName] floatValue];
CGFloat radius = [attributes[BDBCornerRadiusAttributeName] floatValue];

UIColor *fillColor = attributes[BDBAttributedButtonFillColorName];
UIColor *fillColor = attributes[BDBFillColorAttributeName];
if (!fillColor)
fillColor = [UIColor clearColor];

UIColor *borderColor = attributes[BDBAttributedButtonBorderColorName];
UIColor *borderColor = attributes[BDBBorderColorAttributeName];
if (!borderColor)
borderColor = [UIColor clearColor];

CGFloat borderWidth = [attributes[BDBAttributedButtonBorderWidthName] floatValue];
CGFloat borderWidth = [attributes[BDBBorderWidthAttributeName] floatValue];

NSString *identifier =
[NSString stringWithFormat:@"BDBAttributedButtonBackgroundImage_r%0.2f_f%@_b%@_w%0.2f", radius,
Expand Down
6 changes: 3 additions & 3 deletions BDBAttributedButtonDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
E84DFAED188302BE00CCD4DF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
E84DFAEE188302BE00CCD4DF /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E84DFAFC188303E500CCD4DF /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
E84DFAFD188303E500CCD4DF /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
E8674D7B1888C5F200F839E8 /* BDBAttributedButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDBAttributedButton.h; sourceTree = "<group>"; };
E8674D7C1888C5F200F839E8 /* BDBAttributedButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDBAttributedButton.m; sourceTree = "<group>"; };
E84DFAFD188303E500CCD4DF /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MainViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
E8674D7B1888C5F200F839E8 /* BDBAttributedButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = BDBAttributedButton.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
E8674D7C1888C5F200F839E8 /* BDBAttributedButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BDBAttributedButton.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down
10 changes: 5 additions & 5 deletions BDBAttributedButtonDemo/View Controllers/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ - (void)viewDidLoad
NSMutableAttributedString *buttonHighlightedTitle = [buttonTitle mutableCopy];
[buttonHighlightedTitle addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(0, buttonTitle.length)];

NSDictionary *buttonAttributes = @{BDBAttributedButtonCornerRadiusName:@(10.0f), BDBAttributedButtonBorderWidthName:@(1.0f), BDBAttributedButtonBorderColorName:[UIColor redColor]};
NSDictionary *buttonHighlightedAttributes = @{BDBAttributedButtonCornerRadiusName:@(10.0f), BDBAttributedButtonBorderWidthName:@(1.0f), BDBAttributedButtonBorderColorName:[UIColor darkGrayColor]};
NSDictionary *buttonAttributes = @{BDBCornerRadiusAttributeName:@(10.0f), BDBBorderWidthAttributeName:@(1.0f), BDBBorderColorAttributeName:[UIColor redColor]};
NSDictionary *buttonHighlightedAttributes = @{BDBCornerRadiusAttributeName:@(10.0f), BDBBorderWidthAttributeName:@(1.0f), BDBBorderColorAttributeName:[UIColor darkGrayColor]};

BDBAttributedButton *button = [[BDBAttributedButton alloc] initWithFrame:CGRectMake(0.0f, 84.0f, 0.0f, 0.0f)];
[button setAttributedTitle:buttonTitle forState:UIControlStateNormal];
Expand All @@ -62,8 +62,8 @@ - (void)viewDidLoad
buttonHighlightedTitle = [buttonTitle mutableCopy];
[buttonHighlightedTitle addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, buttonTitle.length)];

buttonAttributes = @{BDBAttributedButtonCornerRadiusName:@(10.0f), BDBAttributedButtonBorderWidthName:@(1.0f), BDBAttributedButtonBorderColorName:[UIColor orangeColor]};
buttonHighlightedAttributes = @{BDBAttributedButtonCornerRadiusName:@(10.0f), BDBAttributedButtonFillColorName:[UIColor orangeColor]};
buttonAttributes = @{BDBCornerRadiusAttributeName:@(10.0f), BDBBorderWidthAttributeName:@(1.0f), BDBBorderColorAttributeName:[UIColor orangeColor]};
buttonHighlightedAttributes = @{BDBCornerRadiusAttributeName:@(10.0f), BDBFillColorAttributeName:[UIColor orangeColor]};

button = [[BDBAttributedButton alloc] initWithFrame:CGRectMake(0.0f, CGRectGetMaxY(button.frame) + 16.0f, 0.0f, 0.0f)];
[button setAttributedTitle:buttonTitle forState:UIControlStateNormal];
Expand All @@ -77,7 +77,7 @@ - (void)viewDidLoad

// Button 3: Filled
buttonTitle = [self titleWithString:NSLocalizedString(@"Filled Button", nil) font:buttonFont color:[UIColor whiteColor]];
buttonAttributes = @{BDBAttributedButtonCornerRadiusName:@(10.0f), BDBAttributedButtonFillColorName:[UIColor blueColor]};
buttonAttributes = @{BDBCornerRadiusAttributeName:@(10.0f), BDBFillColorAttributeName:[UIColor blueColor]};

button = [[BDBAttributedButton alloc] initWithFrame:CGRectMake(0.0f, CGRectGetMaxY(button.frame) + 16.0f, 0.0f, 0.0f)];
[button setAttributedTitle:buttonTitle forState:UIControlStateNormal];
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ NSAttributedString *title =
attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

BDBAttributedButton *button = [BDBAttributedButton new];
[button setStyleAttributes:@{BDBAttributedButtonCornerRadiusName:@(5.0f),
BDBAttributedButtonFillColorName:[UIColor red]}
[button setStyleAttributes:@{BDBCornerRadiusAttributeName:@(5.0f),
BDBFillColorAttributeName:[UIColor red]}
forControlState:UIControlStateNormal];
[button setAttributedTitle:title forControlState:UIControlStateNormal];
[button sizeToFit];
Expand Down

0 comments on commit 58a83e7

Please sign in to comment.