Skip to content

Commit d70d12c

Browse files
committed
update WPNUXSecondaryButton to use UIButtonConfiguration API
1 parent 0e1cb3a commit d70d12c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

WooCommerce/WordPressAuthenticator/NUX/WPNUXSecondaryButton.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "WPNUXSecondaryButton.h"
2+
#import <UIKit/UIKit.h>
23
@import WordPressSharedObjC;
34

45

@@ -31,25 +32,34 @@ - (void)sizeToFit
3132

3233
// Adjust frame to account for the edge insets
3334
CGRect frame = self.frame;
34-
frame.size.width += self.titleEdgeInsets.left + self.titleEdgeInsets.right;
35+
frame.size.width += self.configuration.contentInsets.leading + self.configuration.contentInsets.trailing;
3536
self.frame = frame;
3637
}
3738

3839
- (CGSize)intrinsicContentSize
3940
{
4041
CGSize size = [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
41-
size.width += self.titleEdgeInsets.left + self.titleEdgeInsets.right;
42+
size.width += self.configuration.contentInsets.leading + self.configuration.contentInsets.trailing;
4243
return size;
4344
}
4445

4546
#pragma mark - Private Methods
4647

4748
- (void)configureButton
4849
{
50+
UIButtonConfiguration *config = [UIButtonConfiguration plainButtonConfiguration];
51+
config.contentInsets = NSDirectionalEdgeInsetsMake(
52+
WPNUXSecondaryButtonTitleEdgeInsets.top,
53+
WPNUXSecondaryButtonTitleEdgeInsets.left,
54+
WPNUXSecondaryButtonTitleEdgeInsets.bottom,
55+
WPNUXSecondaryButtonTitleEdgeInsets.right
56+
);
57+
self.configuration = config;
58+
4959
self.titleLabel.font = [WPFontManager systemRegularFontOfSize:15.0];
5060
self.titleLabel.minimumScaleFactor = 10.0/15.0;
5161
self.titleLabel.adjustsFontSizeToFitWidth = YES;
52-
[self setTitleEdgeInsets:WPNUXSecondaryButtonTitleEdgeInsets];
62+
5363
[self setTitleColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
5464
[self setTitleColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.4] forState:UIControlStateHighlighted];
5565
}

0 commit comments

Comments
 (0)