3

As far as I know you are able to create your own wrapper around UIKit components (as can be seen in this pull-to-refresh adapation for SwiftUI).

However, I was wondering whether e.g. a SwiftUI Button is, behind the scenes, actually backed by a NSButton or UIButton respectively? Alas, I couldn't find anything in the offical documentation. Is there any statement by Apple on this matter?

Thanks in advance :)

schroffl
  • 579
  • 7
  • 17
  • Open the view debugger and look for yourself – Claus Jørgensen Sep 24 '20 at 15:37
  • Ha, that's a great idea! – schroffl Sep 24 '20 at 15:43
  • 1
    So when I have a SwiftUI app the debugger simply says `Button`, while the label reads `UIButton` in a Storyboard app. So I guess this answer my question with a "no"? Was this also the case in the early days of SwiftUI or was it just a simple wrapper at some point? – schroffl Sep 24 '20 at 15:56
  • Given how the controls work, assuming it's "no" for most things make sense. Some controls, like the Picker, might still be a wrapped UIPicker, but overall you should think of them as new. Aside from curiosity, there's no value to you as a programmer in knowing how it's done anyway. SwiftUI is a entirely different paradigm. – Claus Jørgensen Sep 24 '20 at 16:13
  • Sometimes yes, sometimes no. The tendency goes to "always no", so don't rely in perspective, but in short-term some UIKit-fallback workarounds work. – Asperi Sep 24 '20 at 16:36
  • Thank you very much. Do any of you want to put that in an answer so I can accept it? I could answer and just cite you otherwise. – schroffl Sep 24 '20 at 16:38

0 Answers0