Post

Replies

Boosts

Views

Activity

UIButtonConfiguration Help
Hello, I'm having an issue with UIButtonConfiguration not respecting the constraints of the button. I'm trying to replace a UIButton that contains a titleLabel, but the titleLabel doesn't get transferred over. So I tried setting an attributedTitle to UIButtonConfiguration, and that made the button show, but the constraints were messed up and the button was large. The constraints of the UIView created by UIButtonConfiguration overrode the UIView created from the UIButton. Is there any way to abide by the deprecated API that asks us to use UIButtonConfiguration but respect the other properties of UIButton. It doesn't feel like UIButtonConfiguration is ready for all the functionality needed in a custom UIButton.
Topic: UI Frameworks SubTopic: UIKit Tags:
7
0
1.8k
Apr ’23
Used UIButtonConfiguration, UIButton.titleLabel gets replaced, what is the equivalent refactor?
What is the replacement for UIButton.titleLabel.adjustsFontForContentSizeCategory in UIButtonConfiguration? If I want to replace UIButton.titleLabel in general, I need to create an NSAttributedString and then manipulate it, but I'm not sure if there's a NSAttributeKey for this property. Any help is appreciated! Feel free to add any other refactors that seem relevant!
1
0
1.2k
May ’23
traitCollectionDidChange Triggered Twice In iOS17
In iOS17, traitCollectionDidChange gets triggered twice on iOS17 devices/simulators, while on iOS<17 devices/simulators, it only gets triggered once. I was wondering if there was a reason for this. I'm currently investigating issues between portrait and landscape and UI/view controllers looking weird because of the rotation and trying to figure out what the issue is. I found this thread https://developer.apple.com/forums/thread/732069 which makes me think that code should still work, but looking for any feedback that could help. Thanks!!
1
0
1.8k
Jun ’23
Using UIButtonConfiguration, what is the equivalent to using UIButton.imageEdgeInsets
I can't seem to find the equivalent. I don't think imagePadding is the right UIButtonConfiguration property. What would be the appropriate refactor the header comments just say this // The effect of these properties can be replicated via UIButtonConfiguration.contentInset and UIButtonConfiguration.imageToTitlePadding. They are ignored when a configuration is set. @property(nonatomic) UIEdgeInsets contentEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)) UI_APPEARANCE_SELECTOR; // default is UIEdgeInsetsZero. On tvOS 10 or later, default is nonzero except for custom buttons. @property(nonatomic) UIEdgeInsets titleEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)); // default is UIEdgeInsetsZero @property(nonatomic) UIEdgeInsets imageEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)); // default is UIEdgeInsetsZero And I don't see imageToTitlePadding on Apple's public documentation so I'm not sure how to use it.
5
1
2.6k
Jun ’23
Replacement for adjustsImageWhenHighlighted in UIButton
adjustsImageWhenHighlighted is deprecated and the header says this: @property(nonatomic) BOOL adjustsImageWhenHighlighted API_DEPRECATED("This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler" So far I have this UIButtonConfiguration* buttonConfiguration = [UIButtonConfiguration plainButtonConfiguration]; voice_search_button.configuration = buttonConfiguration; voice_search_button.configurationUpdateHandler = ^(UIButton* button) { }; but how do I make the image darker when highlighted/tapped? I should check if it's being highlighted and if it is then I add a tint to the UIButton? If so, what should that tint be to replicate the system color? Thanks for the help!
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
1.6k
Jun ’23
Clarity on updateTraitsIfNeeded in traitCollectionDidChange
For the method -updateTraitsIfNeeded, if it's ran in traitCollectionDidChange is there a possibility for an infinite loop to trigger because we update the trait and then that triggers another traitCollectionDidChange? I know that the key words are "IfNeeded", but I wanted to make sure that this method forces an update usually once and then doesn't retrigger any traitCollection update logic recursively an infinite amount of time. Any help would be appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
1.5k
Jul ’23
Highlighted color different with UIButtonConfiguration
When a UIButton configured with UIButtonConfiguration is selected and highlighted, my highlight colors are different in dark mode. Here's some relevant code UIColor* kTitleColorStateNormal = [UIColor colorWithWhite:0.0 alpha:1.0]; UIColor* kTitleColorStateHighlighted = [UIColor colorWithWhite:0.0 alpha:0.3]; button.configurationUpdateHandler = ^(UIButton* incomingButton) { UIButtonConfiguration* updatedConfig = incomingButton.configuration; switch (incomingButton.state) { case UIControlStateHighlighted: updatedConfig.baseForegroundColor = kTitleColorStateHighlighted; break; case UIControlStateNormal: updatedConfig.baseForegroundColor = kTitleColorStateNormal; break; default: break; } incomingButton.configuration = updatedConfig; }; This is the code used without UIButtonConfiguration [button setTitleColor:kTitleColorStateNormal forState:UIControlStateNormal]; [button setTitleColor:kTitleColorStateHighlighted forState:UIControlStateHighlighted]; and the output are these screenshots Without UIButtonConfiguration With UIButtonConfiguration The white buttons are what the buttons look like in UIControlStateNormal. I agree that "with UIButtonConfiguration" does look better, but I would like the output to be the same, and it's not. Any help would be appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
1.3k
Jul ’23
How To Set Number Of Lines in UIButtonConfiguration
Hello! This is a follow up to this thread but how do you set the number of lines in a UIButtonConfiguration? I'm assuming that maybe we can do this through using attributedTitle/NSAttributedString, but not sure which property or specific attribute to use. Can I get any help towards setting the amount of lines? Any help is appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
4
1
2.1k
Jul ’23
UIButtonConfiguration Help
Hello, I'm having an issue with UIButtonConfiguration not respecting the constraints of the button. I'm trying to replace a UIButton that contains a titleLabel, but the titleLabel doesn't get transferred over. So I tried setting an attributedTitle to UIButtonConfiguration, and that made the button show, but the constraints were messed up and the button was large. The constraints of the UIView created by UIButtonConfiguration overrode the UIView created from the UIButton. Is there any way to abide by the deprecated API that asks us to use UIButtonConfiguration but respect the other properties of UIButton. It doesn't feel like UIButtonConfiguration is ready for all the functionality needed in a custom UIButton.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
7
Boosts
0
Views
1.8k
Activity
Apr ’23
Used UIButtonConfiguration, UIButton.titleLabel gets replaced, what is the equivalent refactor?
What is the replacement for UIButton.titleLabel.adjustsFontForContentSizeCategory in UIButtonConfiguration? If I want to replace UIButton.titleLabel in general, I need to create an NSAttributedString and then manipulate it, but I'm not sure if there's a NSAttributeKey for this property. Any help is appreciated! Feel free to add any other refactors that seem relevant!
Replies
1
Boosts
0
Views
1.2k
Activity
May ’23
Using UIButtonConfiguration, what is the equivalent refactor for titleLabel.minimumScaleFactor?
I can't seem to find the proper refactor for scaling down the title by using something like UIButton.titleLabel.minimumScaleFactor. Is there something in a NSAttributedString that I could use? If that's the case, I can probably use the attributedTitle property on UIButton.configuration. Let me know what you think!
Replies
1
Boosts
0
Views
685
Activity
May ’23
traitCollectionDidChange Triggered Twice In iOS17
In iOS17, traitCollectionDidChange gets triggered twice on iOS17 devices/simulators, while on iOS<17 devices/simulators, it only gets triggered once. I was wondering if there was a reason for this. I'm currently investigating issues between portrait and landscape and UI/view controllers looking weird because of the rotation and trying to figure out what the issue is. I found this thread https://developer.apple.com/forums/thread/732069 which makes me think that code should still work, but looking for any feedback that could help. Thanks!!
Replies
1
Boosts
0
Views
1.8k
Activity
Jun ’23
Using UIButtonConfiguration, what is the equivalent to using UIButton.imageEdgeInsets
I can't seem to find the equivalent. I don't think imagePadding is the right UIButtonConfiguration property. What would be the appropriate refactor the header comments just say this // The effect of these properties can be replicated via UIButtonConfiguration.contentInset and UIButtonConfiguration.imageToTitlePadding. They are ignored when a configuration is set. @property(nonatomic) UIEdgeInsets contentEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)) UI_APPEARANCE_SELECTOR; // default is UIEdgeInsetsZero. On tvOS 10 or later, default is nonzero except for custom buttons. @property(nonatomic) UIEdgeInsets titleEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)); // default is UIEdgeInsetsZero @property(nonatomic) UIEdgeInsets imageEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0)); // default is UIEdgeInsetsZero And I don't see imageToTitlePadding on Apple's public documentation so I'm not sure how to use it.
Replies
5
Boosts
1
Views
2.6k
Activity
Jun ’23
Replacement for adjustsImageWhenHighlighted in UIButton
adjustsImageWhenHighlighted is deprecated and the header says this: @property(nonatomic) BOOL adjustsImageWhenHighlighted API_DEPRECATED("This property is ignored when using UIButtonConfiguration, you may customize to replicate this behavior via a configurationUpdateHandler" So far I have this UIButtonConfiguration* buttonConfiguration = [UIButtonConfiguration plainButtonConfiguration]; voice_search_button.configuration = buttonConfiguration; voice_search_button.configurationUpdateHandler = ^(UIButton* button) { }; but how do I make the image darker when highlighted/tapped? I should check if it's being highlighted and if it is then I add a tint to the UIButton? If so, what should that tint be to replicate the system color? Thanks for the help!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
2
Boosts
0
Views
1.6k
Activity
Jun ’23
Replacement for titleEdgeInsets and imageEdgeInsets in UIButton For UIButtonConfiguration
The attached documentation for both of these properties API_DEPRECATED("This property is ignored when using UIButtonConfiguration" but what if we wanted to add spacing to the title or image? Just to confirm, is the equivalent refactor to use titlePadding and imagePadding in UIButtonConfiguration?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
1
Boosts
0
Views
2.3k
Activity
Jun ’23
Follow Up: Replacement for adjustsImageWhenHighlighted in UIButton
I made thread, but had a follow up question: What would be the equivalent refactor if we want to adjustsImageWhenHighlighted to be NO? I understood that we could manipulate the image to replicate adjusting the image when highlighted. Is there a way to replicate turning off any image adjustments when highlighted. What would the code look like?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
2
Boosts
0
Views
825
Activity
Jul ’23
Clarity on updateTraitsIfNeeded in traitCollectionDidChange
For the method -updateTraitsIfNeeded, if it's ran in traitCollectionDidChange is there a possibility for an infinite loop to trigger because we update the trait and then that triggers another traitCollectionDidChange? I know that the key words are "IfNeeded", but I wanted to make sure that this method forces an update usually once and then doesn't retrigger any traitCollection update logic recursively an infinite amount of time. Any help would be appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
1
Boosts
0
Views
1.5k
Activity
Jul ’23
Clarity on UIButtonConfiguration contentInsets default value
The default content inset is (top = 7, leading = 12, bottom = 7, trailing = 12), is there a reason this is the default rather than (0,0,0,0)? Is it to make it easier for people to use UIButtonConfiguration without having to fiddle with margin sizes to have elements look right? Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
1
Boosts
0
Views
735
Activity
Jul ’23
Highlighted color different with UIButtonConfiguration
When a UIButton configured with UIButtonConfiguration is selected and highlighted, my highlight colors are different in dark mode. Here's some relevant code UIColor* kTitleColorStateNormal = [UIColor colorWithWhite:0.0 alpha:1.0]; UIColor* kTitleColorStateHighlighted = [UIColor colorWithWhite:0.0 alpha:0.3]; button.configurationUpdateHandler = ^(UIButton* incomingButton) { UIButtonConfiguration* updatedConfig = incomingButton.configuration; switch (incomingButton.state) { case UIControlStateHighlighted: updatedConfig.baseForegroundColor = kTitleColorStateHighlighted; break; case UIControlStateNormal: updatedConfig.baseForegroundColor = kTitleColorStateNormal; break; default: break; } incomingButton.configuration = updatedConfig; }; This is the code used without UIButtonConfiguration [button setTitleColor:kTitleColorStateNormal forState:UIControlStateNormal]; [button setTitleColor:kTitleColorStateHighlighted forState:UIControlStateHighlighted]; and the output are these screenshots Without UIButtonConfiguration With UIButtonConfiguration The white buttons are what the buttons look like in UIControlStateNormal. I agree that "with UIButtonConfiguration" does look better, but I would like the output to be the same, and it's not. Any help would be appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
1.3k
Activity
Jul ’23
How To Set Number Of Lines in UIButtonConfiguration
Hello! This is a follow up to this thread but how do you set the number of lines in a UIButtonConfiguration? I'm assuming that maybe we can do this through using attributedTitle/NSAttributedString, but not sure which property or specific attribute to use. Can I get any help towards setting the amount of lines? Any help is appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
4
Boosts
1
Views
2.1k
Activity
Jul ’23
UIButtonConfiguration equivalent to titleLabel.adjustsFontSizeToFitWidth
Follow up to this thread, does adjustsFontSizeToFitWidth also follow the same thinking? Is it assumed that if we use a font style, this doesn't need to be set in a UIButton if we're using UIButtonConfiguration?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
2
Boosts
0
Views
1.3k
Activity
Aug ’24