-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Drop iOS 14 Support: Address UIButton API deprecations (#1) #20897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3592d01
ea0a848
3ab4e43
34f88bd
4470559
745ebf3
44943c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,14 +64,20 @@ - (void)setupCancelButton | |
| button.titleLabel.adjustsFontForContentSizeCategory = YES; | ||
| [button setTitle:NSLocalizedString(@"Cancel", @"") forState:UIControlStateNormal]; | ||
|
|
||
| UIEdgeInsets inset = button.contentEdgeInsets; | ||
| inset.left = 6.0; | ||
| inset.right = inset.left; | ||
| button.contentEdgeInsets = inset; | ||
| if (@available(iOS 15, *)) { | ||
| UIButtonConfiguration *configuration = [UIButtonConfiguration plainButtonConfiguration]; | ||
| configuration.contentInsets = NSDirectionalEdgeInsetsMake(0, 6, 0, 6); | ||
| button.configuration = configuration; | ||
| } else { | ||
| UIEdgeInsets inset = button.contentEdgeInsets; | ||
| inset.left = 6.0; | ||
| inset.right = inset.left; | ||
| button.contentEdgeInsets = inset; | ||
| } | ||
| button.hidden = YES; | ||
|
|
||
| [self.accessoryStackView addArrangedSubview:button]; | ||
| [button setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; | ||
| [button setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why hugging behavior changes with the new button configuration. I couldn't find any related documentation. I asked on Mastodon, and other folks also encountered it. The goal is to ensure the label on the right has a lower hugging priority. |
||
| [button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; | ||
|
|
||
| NSLayoutConstraint *heightConstraint = [button.heightAnchor constraintEqualToAnchor:self.accessoryStackView.heightAnchor]; | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import UIKit | ||
|
|
||
| // Temporary converted to Swift silence the compiler warnings that are treated | ||
| // as errors in Objective-C files. | ||
| final class PostMetaButton: UIButton { | ||
| override var intrinsicContentSize: CGSize { | ||
| var newSize = super.intrinsicContentSize | ||
| newSize.width += (imageEdgeInsets.left + imageEdgeInsets.right) | ||
| newSize.width += (titleEdgeInsets.left + titleEdgeInsets.right) | ||
| return newSize | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no-op because
trueis the default value. (Yes, it's deprecated in iOS 15).