有没有办法知道touch 点上像素的亮度,例如,如果我想知道屏幕上这些形状中每个像素的亮度?
struct ContentView: View {
@State var brightness = 0.0
var body: some View {
VStack {
Rectangle()
.frame(width: 100,height: 100)
.foregroundColor(.black)
Circle()
.frame(width: 100,height: 100)
.foregroundColor(.gray)
RoundedRectangle(cornerRadius: 30)
.frame(width: 100,height: 100)
.foregroundColor(.gray.opacity(0.5))
Text("brightness = \(brightness)")
.font(.largeTitle)
}
}
}