我想设置 Popover 页面的位置和大小。
func popover的所有参数我都试过了,我觉得可能和attachmentAnchor和arrowEdge有关。
这是我的代码:
import SwiftUI
struct ContentView : View {
@State var isPop = false
var body: some View {
VStack{
Button("Pop", action: {self.isPop = true})
.popover(isPresented: $isPop, attachmentAnchor: .point(UnitPoint(x: 20, y: 20)), arrowEdge: .top, content: {return Rectangle().frame(height: 100).foregroundColor(Color.blue)})
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想要的效果:
Xcode11 beta5中swiftUI的Path.fill和.stroke不起作用
下面的代码在Xcode beta4中工作正常,但在Xcode beta5中崩溃,我得到的所有错误信息都是:线程1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)
代码:
import SwiftUI
struct ContentView: View {
var body: some View {
Path{path in
path.addRect(CGRect(x: 20, y: 20, width: 300, height: 200))
}.fill(Color.red)
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Run Code Online (Sandbox Code Playgroud)