Meet the UIKit button system

RSS for tag

Discuss the WWDC21 session Meet the UIKit button system.

Posts under wwdc21-10064 tag

9 Posts

Post

Replies

Boosts

Views

Activity

When using UIButton.Configuration it's impossible to limit number of lines of the button's title label
Up until iOS 15 it was possible to set maximum number of lines of the UIButton titleLabel property, but when UIButton.Configuration is used to configure button's properties setting the titleLabel?.numberOfLines to any value is always ignored and reset after assigning text to configuration. See the short piece of code below: import UIKit let button = UIButton(configuration: .plain()) button.titleLabel?.numberOfLines = 1 print("Lines: \(button.titleLabel?.numberOfLines ?? 999)") // <- prints "Lines: 1" var buttonConfiguration = button.configuration buttonConfiguration?.title = "Any text" button.configuration = buttonConfiguration print("Lines: \(button.titleLabel?.numberOfLines ?? 999)") // <- prints "Lines: 0" Even if you set the numberOfLines to 1 it is ignored and the button renders one, or more lines of text. I think it's a bug, there is no compiler warning about accessing the titleLabel property, as there is with imageEdgeInsets for example. If you access that one Xcode gives you a warning 'imageEdgeInsets' was deprecated in iOS 15.0: This property is ignored when using UIButtonConfiguration If modifying titleLabel directly there should be a warning as well, but if that's the case, the UIButton.Configuration is seriously lacking some features, like setting maximum number of lines, or even a font (this can be done via AttributedString but setting font is so common that constructing AttrbitutedString every time the title is changed feels so wrong and unnecessary) For the time being I'm forced to use the legacy button customisation
3
0
4.4k
Oct ’23
Displaying a subtitle for nested UIMenus
The sessions talks about a new subtitle ability for UIMenus (“These buttons also benefit from improvements in menus like the ability for menu items to have subtitles for greater clarity.”) but I cannot find documentation on how to enable said subtitle. Even using the example code with the new .singleSelection option does not display any subtitle.. Anyone did succeed in doing so?
2
0
2.3k
May ’22
Time to get an answer from Apple supporters?
My company has a product that is a kind of Endpoint Security Application. We haven't had its entitlement. So we submit a request to register Endpoint Security Extension entitlement on the Apple website. After submitting the request, we received an automatic email from Apple, they said that they will review our request and they will send us an email when they evaluate our information. But after a few weeks, I haven't received any email from Apple and I don't know whether my request is accepted or not? In the case my request is rejected, will I get an answer email from Apple? And how long to get their answer? Currently, our product is finished with development but we don't have the entitlement to publicize it. Thanks, Phu Luu
1
0
1k
Mar ’22
how to have 2 functions with one button
I was wondering how i could have 2 functions work from 1 button. One would happen on the first time you click and second will happen the second time you click. in java something like this: if button pressed{ // Code if button pressed{ // Code } } or at least that's how I was taught in java. so I'm wondering how I could do that in swift. Thanks!
1
0
889
Feb ’22
The new UIButton.Configuration Api no subtle color transition
When I create a UIButton by new iOS15 api: UIButton(configuration: .plain(), primaryAction: nil) I lose the title fade transition that is provided by UIButton which created by old api: UIButton(type: .system) This is a feature or bug? I think it is bad that system control lost the subtle animation. I hope Apple can fix it in the future version. May I used it wrong? If I'm wrong, please help me fix it, thanks🙏
2
0
2.2k
Feb ’22
Action Button(Textfield)
Good day, I would like to generate a text field when I tap on the green button that creates a new text field and I can still enter for example a 2nd phone number. I have already tried it with this example: Button(action: { print("Telefonnummer")}) {          Image(systemName: "plus.circle.fill")                 .foregroundColor(Color(.systemGreen)) }
8
0
3.0k
Jan ’22
When using UIButton.Configuration it's impossible to limit number of lines of the button's title label
Up until iOS 15 it was possible to set maximum number of lines of the UIButton titleLabel property, but when UIButton.Configuration is used to configure button's properties setting the titleLabel?.numberOfLines to any value is always ignored and reset after assigning text to configuration. See the short piece of code below: import UIKit let button = UIButton(configuration: .plain()) button.titleLabel?.numberOfLines = 1 print("Lines: \(button.titleLabel?.numberOfLines ?? 999)") // <- prints "Lines: 1" var buttonConfiguration = button.configuration buttonConfiguration?.title = "Any text" button.configuration = buttonConfiguration print("Lines: \(button.titleLabel?.numberOfLines ?? 999)") // <- prints "Lines: 0" Even if you set the numberOfLines to 1 it is ignored and the button renders one, or more lines of text. I think it's a bug, there is no compiler warning about accessing the titleLabel property, as there is with imageEdgeInsets for example. If you access that one Xcode gives you a warning 'imageEdgeInsets' was deprecated in iOS 15.0: This property is ignored when using UIButtonConfiguration If modifying titleLabel directly there should be a warning as well, but if that's the case, the UIButton.Configuration is seriously lacking some features, like setting maximum number of lines, or even a font (this can be done via AttributedString but setting font is so common that constructing AttrbitutedString every time the title is changed feels so wrong and unnecessary) For the time being I'm forced to use the legacy button customisation
Replies
3
Boosts
0
Views
4.4k
Activity
Oct ’23
Displaying a subtitle for nested UIMenus
The sessions talks about a new subtitle ability for UIMenus (“These buttons also benefit from improvements in menus like the ability for menu items to have subtitles for greater clarity.”) but I cannot find documentation on how to enable said subtitle. Even using the example code with the new .singleSelection option does not display any subtitle.. Anyone did succeed in doing so?
Replies
2
Boosts
0
Views
2.3k
Activity
May ’22
Time to get an answer from Apple supporters?
My company has a product that is a kind of Endpoint Security Application. We haven't had its entitlement. So we submit a request to register Endpoint Security Extension entitlement on the Apple website. After submitting the request, we received an automatic email from Apple, they said that they will review our request and they will send us an email when they evaluate our information. But after a few weeks, I haven't received any email from Apple and I don't know whether my request is accepted or not? In the case my request is rejected, will I get an answer email from Apple? And how long to get their answer? Currently, our product is finished with development but we don't have the entitlement to publicize it. Thanks, Phu Luu
Replies
1
Boosts
0
Views
1k
Activity
Mar ’22
how to have 2 functions with one button
I was wondering how i could have 2 functions work from 1 button. One would happen on the first time you click and second will happen the second time you click. in java something like this: if button pressed{ // Code if button pressed{ // Code } } or at least that's how I was taught in java. so I'm wondering how I could do that in swift. Thanks!
Replies
1
Boosts
0
Views
889
Activity
Feb ’22
The new UIButton.Configuration Api no subtle color transition
When I create a UIButton by new iOS15 api: UIButton(configuration: .plain(), primaryAction: nil) I lose the title fade transition that is provided by UIButton which created by old api: UIButton(type: .system) This is a feature or bug? I think it is bad that system control lost the subtle animation. I hope Apple can fix it in the future version. May I used it wrong? If I'm wrong, please help me fix it, thanks🙏
Replies
2
Boosts
0
Views
2.2k
Activity
Feb ’22
Action Button(Textfield)
Good day, I would like to generate a text field when I tap on the green button that creates a new text field and I can still enter for example a 2nd phone number. I have already tried it with this example: Button(action: { print("Telefonnummer")}) {          Image(systemName: "plus.circle.fill")                 .foregroundColor(Color(.systemGreen)) }
Replies
8
Boosts
0
Views
3.0k
Activity
Jan ’22