Meet the UIKit button system

RSS for tag

Discuss the WWDC21 session Meet the UIKit button system.

Posts under wwdc21-10064 tag

15 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.3k
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.2k
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
994
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
866
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
2.9k
Jan ’22
wwdc21-10064 Stat
Hi everyone , just started to have a look about XCode and SWIFT unite and after creating my struct ContentView: view i wanted to put a BTN that start he AR experience (with the function to scan an element from a voucher) Btw i didn't manage to start the camera opening with the press of the Btn. Knowing that this is a very basic question i ll ty in advice who is gonna spend some time for an ansewr.
0
0
811
Nov ’21
Pop Up buttons in Interface Builder don't show menu in iOS 15
Hi, guys. I'm testing the new pop-up and pull-down buttons in iOS 15, but they do not show the pop-up menu when pressed (all the options in the Attributes Inspector panel are checked). They only work when I define the entire menu in code. My questions are: Is this because the feature was not implemented yet? If this is implemented later and we can define the menu in Interface Builder, how do you respond to a selection? In code, I can specify the action in the closure, but how do I do it if the menu is defined in Interface Builder? This is how I define the menu from code, just in case someone needs to know: import UIKit class ViewController: UIViewController {   @IBOutlet weak var myButton: UIButton!   override func viewDidLoad() {    super.viewDidLoad()         let optionsClosure = { (action: UIAction) in      print(action.title)    }    myButton.menu = UIMenu(children: [      UIAction(title: "Option 1", state: .on, handler: optionsClosure),      UIAction(title: "Option 2", handler: optionsClosure),      UIAction(title: "Option 3", handler: optionsClosure)    ])   } } Thanks JD
3
0
5.1k
Nov ’21
button freeze
when i press on button that shows another vc that contains search bar the button freeze for 2 sec then redirect me to the view controller and this happens for the first time only I tired to hash my logic and keeps only the search bar but nothing worked just when I delete the search bar everything goes right
1
0
551
Oct ’21
Objects to storyboard not seen
Being new at this, I created a new swift project. The default code build and the 'hello world' shows in the simulator. I added a text and a button object by dragging them onto the storybook. Now running the project the text briefly shows, the button does not, and then the text disappears and the 'hello world' shows. I cannot find a simple sample project to start with that might have such objects and all the queries online have not been explicit as to how to make this work.
0
0
475
Aug ’21
Help with iOS 15 UIButton?
I am trying to construct a button using the new iOS15 button API. (Xcode 13ß3, UIKit & Storyboards) The button has a title (aligned .leading) and an image (aligned .trailing). The button has the following layout constraints: a fixed leading constraint (to a label that provides prompt text) a center-vertically constraint (to that same label) a trailing constraint ( >= a margin value) What I’m trying to accomplish is that the button should adjust its width based on the title content, not wrapping until the width causes the trailing constraint to be violated. What actually happens is the the button’s text wraps. It acts as if it prefers wrapping to changing its size. There are mentions in the documentation about disabling text wrapping for the button, but the obvious things, such as button.titleLabel?.lineBreakMode = .byTruncatingMiddle don’t work. Has anyone whose tried working with iOS 15 buttons have any suggestions?
0
0
2.3k
Jul ’21
How use new UIkit Button system?
Hello, I know it could be a beginner question but I have been searching for examples and I couldn't found examples of a full "live circle" of how to create a button, and customized it considering the new ways presenting in WWDC21. So far, I only know the "Button(action: , label: )" way, where I customize my button in the label section. For example, Im looking to use del .filled() configuration presented in the video about buttons. Thank you for your comments, Franca
2
0
668
Jul ’21
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.3k
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.2k
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
994
Activity
Mar ’22
Input Box
We found that it can't obtain the content of input box in iOS15. When will fix this bug?
Replies
1
Boosts
0
Views
1.2k
Activity
Mar ’22
Using button in custom cell from another ViewController
Hello everyone, I created button in my custom cell, when the user click the that button, I have to segue another class and also I have to pass some data but problem is I could not segue in custom cell, so how can I detect when user tap that button ? or how can I solve this problem
Replies
2
Boosts
0
Views
809
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
866
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
Is there a way to layout UIKit UIButton title & subtitle horizontally?
I'd like to have the title and subtitle of a UIKit UIButton both on the horizontal axis. I didn't see a configuration option for such. Is there a way to do so? Thanks
Replies
2
Boosts
0
Views
976
Activity
Jan ’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
2.9k
Activity
Jan ’22
wwdc21-10064 Stat
Hi everyone , just started to have a look about XCode and SWIFT unite and after creating my struct ContentView: view i wanted to put a BTN that start he AR experience (with the function to scan an element from a voucher) Btw i didn't manage to start the camera opening with the press of the Btn. Knowing that this is a very basic question i ll ty in advice who is gonna spend some time for an ansewr.
Replies
0
Boosts
0
Views
811
Activity
Nov ’21
Pop Up buttons in Interface Builder don't show menu in iOS 15
Hi, guys. I'm testing the new pop-up and pull-down buttons in iOS 15, but they do not show the pop-up menu when pressed (all the options in the Attributes Inspector panel are checked). They only work when I define the entire menu in code. My questions are: Is this because the feature was not implemented yet? If this is implemented later and we can define the menu in Interface Builder, how do you respond to a selection? In code, I can specify the action in the closure, but how do I do it if the menu is defined in Interface Builder? This is how I define the menu from code, just in case someone needs to know: import UIKit class ViewController: UIViewController {   @IBOutlet weak var myButton: UIButton!   override func viewDidLoad() {    super.viewDidLoad()         let optionsClosure = { (action: UIAction) in      print(action.title)    }    myButton.menu = UIMenu(children: [      UIAction(title: "Option 1", state: .on, handler: optionsClosure),      UIAction(title: "Option 2", handler: optionsClosure),      UIAction(title: "Option 3", handler: optionsClosure)    ])   } } Thanks JD
Replies
3
Boosts
0
Views
5.1k
Activity
Nov ’21
button freeze
when i press on button that shows another vc that contains search bar the button freeze for 2 sec then redirect me to the view controller and this happens for the first time only I tired to hash my logic and keeps only the search bar but nothing worked just when I delete the search bar everything goes right
Replies
1
Boosts
0
Views
551
Activity
Oct ’21
Objects to storyboard not seen
Being new at this, I created a new swift project. The default code build and the 'hello world' shows in the simulator. I added a text and a button object by dragging them onto the storybook. Now running the project the text briefly shows, the button does not, and then the text disappears and the 'hello world' shows. I cannot find a simple sample project to start with that might have such objects and all the queries online have not been explicit as to how to make this work.
Replies
0
Boosts
0
Views
475
Activity
Aug ’21
Help with iOS 15 UIButton?
I am trying to construct a button using the new iOS15 button API. (Xcode 13ß3, UIKit & Storyboards) The button has a title (aligned .leading) and an image (aligned .trailing). The button has the following layout constraints: a fixed leading constraint (to a label that provides prompt text) a center-vertically constraint (to that same label) a trailing constraint ( >= a margin value) What I’m trying to accomplish is that the button should adjust its width based on the title content, not wrapping until the width causes the trailing constraint to be violated. What actually happens is the the button’s text wraps. It acts as if it prefers wrapping to changing its size. There are mentions in the documentation about disabling text wrapping for the button, but the obvious things, such as button.titleLabel?.lineBreakMode = .byTruncatingMiddle don’t work. Has anyone whose tried working with iOS 15 buttons have any suggestions?
Replies
0
Boosts
0
Views
2.3k
Activity
Jul ’21
How use new UIkit Button system?
Hello, I know it could be a beginner question but I have been searching for examples and I couldn't found examples of a full "live circle" of how to create a button, and customized it considering the new ways presenting in WWDC21. So far, I only know the "Button(action: , label: )" way, where I customize my button in the label section. For example, Im looking to use del .filled() configuration presented in the video about buttons. Thank you for your comments, Franca
Replies
2
Boosts
0
Views
668
Activity
Jul ’21