struct FrameCGFloatAndDouble: View {
let value = 12.234
let optional: Double? = 12.234
var body: some View {
Text("Hello")
.frame(minHeight: value) // okay
.frame(minHeight: optional) // error: Cannot convert value of type 'Double?' to expected argument type 'CGFloat?'
}
}
Running this in playground I get the error on // okay row:
import Foundation
import PlaygroundSupport
import SwiftUI
struct FrameCGFloatAndDouble: View {
let value = 12.234
let optional: Double? = 12.234
var body: some View {
Text("Hello")
.frame(minHeight: value) // okay
.frame(minHeight: optional) // error: Cannot convert value of type 'Double?' to expected argument type 'CGFloat?'
}
}
I tnink you might be running a version of Xcode which doesn't support Double <-> CGFloat conversions. You can try a snapshot of 5.5 or main and it should work.
We did it only for value -> optional because optional <-> optional conversions are hard to represent via the mechanism we are using to implement this (calling Double.init or CGFloat.init implicitly) because there could be multiple levels of optionality that have to be matched. I guess one way to implement that might be to use linked flatMap implicitly e.g.