From 959ab6e68d834c4a1142bacebfb6fa6cdcb91d85 Mon Sep 17 00:00:00 2001 From: Jeffrey Bergier Date: Mon, 6 May 2019 14:48:18 +0900 Subject: [PATCH 1/2] Added attributedText property --- TORoundedButton/TORoundedButton.h | 4 ++++ TORoundedButton/TORoundedButton.m | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/TORoundedButton/TORoundedButton.h b/TORoundedButton/TORoundedButton.h index 17b20b2..a640f59 100644 --- a/TORoundedButton/TORoundedButton.h +++ b/TORoundedButton/TORoundedButton.h @@ -33,6 +33,10 @@ IB_DESIGNABLE @interface TORoundedButton : UIControl /** The text that is displayed in center of the button (Default is "Button") */ @property (nonatomic, copy) IBInspectable NSString *text; +/** The Attributed string used in the label of this button (Default is nil) */ +/** See UILabel `attributedText` property  documentation for full details. */ +@property (nonatomic, copy, nullable) NSAttributedString *attributedText; + /** The radius of the corners of this button (Default is 10.0f) */ @property (nonatomic, assign) IBInspectable CGFloat cornerRadius; diff --git a/TORoundedButton/TORoundedButton.m b/TORoundedButton/TORoundedButton.m index 5fde841..0caba11 100644 --- a/TORoundedButton/TORoundedButton.m +++ b/TORoundedButton/TORoundedButton.m @@ -429,6 +429,16 @@ - (void)setButtonScaledTappedAnimated:(BOOL)animated #pragma mark - Public Accessors - +- (void)setAttributedText:(NSAttributedString *)attributedText +{ + self.titleLabel.attributedText = attributedText; +} + +- (NSAttributedString *)attributedText +{ + return self.titleLabel.attributedText; +} + - (void)setText:(NSString *)text { self.titleLabel.text = text; From a07123291b451564e703ff372679beb7abf361ef Mon Sep 17 00:00:00 2001 From: Jeffrey Bergier Date: Mon, 6 May 2019 15:43:01 +0900 Subject: [PATCH 2/2] added attributed string to sample project --- .../Base.lproj/Main.storyboard | 3 ++ TORoundedButtonExample/ViewController.h | 4 ++ TORoundedButtonExample/ViewController.m | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/TORoundedButtonExample/Base.lproj/Main.storyboard b/TORoundedButtonExample/Base.lproj/Main.storyboard index 3e0993f..52d91fd 100644 --- a/TORoundedButtonExample/Base.lproj/Main.storyboard +++ b/TORoundedButtonExample/Base.lproj/Main.storyboard @@ -28,6 +28,9 @@ + + +