SwiftUI missed components

Hi everyone, as many of you are doing, I’m also trying my hand at studying the new Apple, SwiftUI framework.
Surely it was a surprise and we can’t wait to see the progress of this framework. But unfortunately I have great difficulties. as perhaps many of you have noticed, some components that we find for example in UIKit are not in SwiftUI. one of these is the UICollectionViewController. My app uses this component a lot and, since I would like to recreate it with SwiftUI, I don’t know how to proceed. one way also shown in the Apple Tutorial is to wrap it in a UIViewRepresentable. but is this convenient for a collectionView? If it’s better, instead, to create one from scratch, do you have any suggestions to give me? keep in mind that the collection view recalculated the number of cells even when the screen was rotated.

Hi @rufy, from my understanding it seems like we can create scrolling lists that can essentially mimic a collection view. I’m not sure if it’s convenient to wrap the UICollectionView in UIViewRepresentable but hopefully we can get more people to chime in. I don’t believe there is currently an equivalent to UICollectionView for SwiftUI at the moment. Below is an example of creating a view that displays a list which I think might closely resemble a UICollectionView. Best, Gina

import SwiftUI

struct Food {
var id: Int
var title: String
var image: String

struct ContentView : View {

let foodItems: [Food] = [
    Food(id: 0, title: "Pizza", image: "0")
    Food(id: 1, title: "Burrito", image: "1")
    Food(id: 2, title: "Sushi", image: "2")
var body: some View {
        NavigationView {
        ScrollView {
            HStack {
            ForEach(foods.identified(by: \.id)) { food in
                FoodView(food: food)

struct FoodView: View {
let food: Food
var body: some View {
VStack {
   .frame(width: 80, height: 80)

Hi @rufy,
The cool thing about SwiftUI is that it kind of breaks from the specific types of controls and provides you, the developer to create what you want. You can use A combination of them to create some really complex layouts. Creating the App Store layout is much simpler with SwiftUI than it is with UIKit or AppKit.


This topic was automatically closed after 166 days. New replies are no longer allowed.