Post

Replies

Boosts

Views

Activity

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!
4
1
1.4k
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!
0
0
959
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!
1
0
1.2k
Jul ’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!
2
0
1.2k
Jun ’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.3k
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
0
1.9k
May ’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
899
May ’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.
7
0
1.3k
Apr ’23