Is SwiftUI build on top of UIKit?

Viewed 60

i can't explain why extension on UIKit's UIPickerView affects on SwiftUI's picker.

and does that mean that knowing basics of uikit is very useful for learning swiftui?

does it even make sense to learn swiftUI if it's basically UIkit library(if I am right)

extension UIPickerView {
    open override var intrinsicContentSize: CGSize {
        return CGSize(width: UIView.noIntrinsicMetric, height: 200)
 }
}



GeometryReader { geometry in
            HStack(spacing: 0) {
                Picker(selection: self.$daySelection, label: Text("")) {
                    ForEach(0 ..< self.days.count) { index in
                        Text("\(self.days[index]) d").tag(index)
                    }
                }
                .pickerStyle(.wheel)
                Picker(selection: self.$daySelection, label: Text("")) {
                    ForEach(0 ..< self.days.count) { index in
                        Text("\(self.days[index]) d").tag(index)
                    }
                }
                .pickerStyle(.wheel)
                Picker(selection: self.$daySelection, label: Text("")) {
                    ForEach(0 ..< self.days.count) { index in
                        Text("\(self.days[index]) d").tag(index)
                    }
                }
                .pickerStyle(.wheel)

MultiPicker

This extension solves problem of overlapping gesture areas of pickers in ios 15.

1 Answers
  1. Is SwiftUI built on top of UIKit?

No... and yes, sometimes.

There are controls in SwiftUI that do reach into UIKit to use those. Although, not all of them.

And as Vacawama rightly pointed out… if running on MacOS then AppKit also.

The thing about SwiftUI is to not worry too much about the underlying technology. It may be that Apple chooses to significantly rewrite the foundation of it. Perhaps taking a previously used UIKit component and writing it natively in SwiftUI. But the SwiftUI code shouldn’t change.

  1. Is SwiftUI a UIKit library?

No, absolutely not. They are fundamentally different ways of thinking about and creating UI.

  1. Does it make sense to learn SwiftUI?

Yes, it makes sense to learn SwiftUI AND UIKit. Also, Combine and CoreGraphics and GameKit... Do you want to be an iOS developer or a SwiftUI developer?

  1. Random bit of badly indented code...

I'm not sure what this is doing in your question.

Related