From 904a7a20a9ddd5d20d00113c83335bd49fb376ed Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Mon, 9 Dec 2013 16:49:36 -0800 Subject: [PATCH] Use image instead of image name to allow for stretchable images. --- EasyLayoutLibrary/ButtonMaker.h | 3 ++- EasyLayoutLibrary/ButtonMaker.m | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/EasyLayoutLibrary/ButtonMaker.h b/EasyLayoutLibrary/ButtonMaker.h index c4832c6..e2cec5a 100644 --- a/EasyLayoutLibrary/ButtonMaker.h +++ b/EasyLayoutLibrary/ButtonMaker.h @@ -14,7 +14,8 @@ + (UIButton *)outerButtonWithNormalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName transparentOuterArea:(CGSize)outerArea; + (UIButton *)plainButtonWithNormalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName; + (UIButton *)plainButtonWithNormalImage:(UIImage *)normalImage selectedImage:(UIImage *)selectedImage; -+ (UIButton *)textButtonWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)color normalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName; ++ (UIButton *)textButtonWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)color + normalImage:(UIImage *)normalImage selectedImage:(UIImage *)selectedImage; + (void)setText:(NSString *)text forButton:(UIButton *)button maxSize:(CGSize)maxSize; + (void)setText:(NSString *)text forButton:(UIButton *)button maxWidth:(CGFloat)maxWidth; diff --git a/EasyLayoutLibrary/ButtonMaker.m b/EasyLayoutLibrary/ButtonMaker.m index a0b86ef..32c56ef 100644 --- a/EasyLayoutLibrary/ButtonMaker.m +++ b/EasyLayoutLibrary/ButtonMaker.m @@ -14,7 +14,7 @@ + (UIButton *)genericButtonWithTitle:(NSString *)title target:(id)target action: { UIButton *newButton = [ButtonMaker textButtonWithText:title font:[UIFont systemFontOfSize:25.0f] color:[UIColor colorWithRed:27.0f/255.0f green:119.0f/255.0f blue:255.0f/255.0f alpha:1.0f] - normalImageName:nil selectedImageName:nil]; + normalImage:nil selectedImage:nil]; [newButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; @@ -33,12 +33,9 @@ + (UIButton *)plainButtonWithNormalImage:(UIImage *)normalImage selectedImage:(U return newButton; } -+ (UIButton *)textButtonWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)color normalImageName:(NSString *)normalImageName selectedImageName:(NSString *)selectedImageName ++ (UIButton *)textButtonWithText:(NSString *)text font:(UIFont *)font color:(UIColor *)color + normalImage:(UIImage *)normalImage selectedImage:(UIImage *)selectedImage { - UIImage *normalImage = [UIImage imageNamed:normalImageName]; - UIImage *selectedImage = [UIImage imageNamed:selectedImageName]; - - UIButton *newButton = [UIButton buttonWithType:UIButtonTypeCustom]; [newButton setTitleColor:color forState:UIControlStateNormal];