1

为什么 Color.yellow 在我的 iPhone X 上显示为棕色,但在我的模拟器中显示为黄色?这不是显示问题,因为测试应用程序的 iPhone X 屏幕截图显示:

截屏

如您所见,Color(red: 1.0, green: 1.0, blue: 0.0)(右下方的正方形)显示为黄色,但Color.yellow(圆圈)显示为棕色。这是生成屏幕截图的代码:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            ForEach(0...4, id: \.self) { green in
                HStack {
                    ForEach(0...4, id: \.self) { red in
                        Color(red: Double(red)/4.0, green: Double(green)/4.0, blue: 0.0)
                    }
                }
            }
            Circle().foregroundColor(.yellow)
        }
    }
}
4

0 回答 0