PageViewController-白色背景

问题描述 投票:0回答:1

我正在尝试将.background修饰符应用于由PageViewController表示的卡。

红色背景未应用于我的卡,因为该卡似乎具有默认的白色背景。

He're my file and preview

import SwiftUI

struct PageView<Page:View>: View {

    var viewControllers: [UIHostingController<Page>]

    init(_ views: [Page]) {
        self.viewControllers = views.map { UIHostingController(rootView: $0)}
    }

    var body: some View {


        ZStack {

            Color.black
                .edgesIgnoringSafeArea(.all)

            PageViewController(controllers: viewControllers)
                .background(Color.red)

        }


    }

}

struct PageView_Previews: PreviewProvider {
    static var previews: some View {
        PageView(cards.map { OnboardingCardView(card: $0) })
    }
}

每张卡都来自CardView,这里没有背景应用于我的卡。

这里有什么问题?非常感谢。

uiview uiviewcontroller swiftui
1个回答
0
投票

您是否在页面viewController的UIKit中设置背景?好像s white. If you want to control it in SwiftUI, in UIKit it should be set to .clear`,我认为。

© www.soinside.com 2019 - 2024. All rights reserved.