@@ -128,6 +128,7 @@ - (void)roundedButtonCommonInit
128128 self.titleLabel .adjustsFontForContentSizeCategory = YES ;
129129 self.titleLabel .backgroundColor = self.tintColor ;
130130 self.titleLabel .text = @" Button" ;
131+ [self .titleLabel sizeToFit ];
131132 [self .containerView addSubview: self .titleLabel];
132133
133134 // Create action events for all possible interactions with this control
@@ -144,7 +145,6 @@ - (void)layoutSubviews
144145 [super layoutSubviews ];
145146
146147 // Configure the button text
147- [self .titleLabel sizeToFit ];
148148 self.titleLabel .center = self.containerView .center ;
149149 self.titleLabel .frame = CGRectIntegral (self.titleLabel .frame );
150150}
@@ -322,6 +322,8 @@ - (void)setButtonScaledTappedAnimated:(BOOL)animated
322322- (void )setAttributedText : (NSAttributedString *)attributedText
323323{
324324 self.titleLabel .attributedText = attributedText;
325+ [self .titleLabel sizeToFit ];
326+ [self setNeedsLayout ];
325327}
326328
327329- (NSAttributedString *)attributedText
@@ -332,6 +334,8 @@ - (NSAttributedString *)attributedText
332334- (void )setText : (NSString *)text
333335{
334336 self.titleLabel .text = text;
337+ [self .titleLabel sizeToFit ];
338+ [self setNeedsLayout ];
335339}
336340- (NSString *)text { return self.titleLabel .text ; }
337341
@@ -404,6 +408,11 @@ - (void)setEnabled:(BOOL)enabled
404408 self.containerView .alpha = enabled ? 1 : 0.4 ;
405409}
406410
411+ - (CGFloat)minimumWidth
412+ {
413+ return self.titleLabel .frame .size .width ;
414+ }
415+
407416#pragma mark - Graphics Handling -
408417
409418+ (UIColor *)brightnessAdjustedColorWithColor : (UIColor *)color amount : (CGFloat)amount
0 commit comments