如何解决SwiftUI:对齐问题、样式表、填充
我是堆栈溢出的新手。我想要的是右上角的信息按钮。没有背景,只有白色的图标。我目前在底部有一个黑色背景,左下角有一个图标。我有按钮工作,但我无法正确定位。有人能告诉我我哪里出错了吗?这是我的代码和当前位置。
控制视图:
{
"kind": "calendar#freeBusy","timeMin": "2021-03-25T03:42:20.000Z","timeMax": "2021-03-25T14:42:20.000Z","calendars": {
"calendar id here": {
"busy": [
{
"start": "2021-03-25T11:42:20+08:00","end": "2021-03-25T13:30:00+08:00"
},{
"start": "2021-03-25T15:45:00+08:00","end": "2021-03-25T17:45:00+08:00"
},{
"start": "2021-03-25T19:00:00+08:00","end": "2021-03-25T22:42:20+08:00"
}
]
}
}
}
内容视图:
import SwiftUI
struct ControlView: View {
@Binding var showInfo: Bool
var body: some View {
ZStack {
HStack{
Spacer()
// Info Button
ControllButton(systemIconName: "info.circle") {
print("Info Button pressed")
self.showInfo.toggle()
}.sheet(isPresented: $showInfo,content: {
// InfoView
InfoView(showInfo: $showInfo)
})
}
.frame(maxWidth: 500)
.padding()
.background(Color.black.opacity(0.05))
}
Spacer()
}
}
struct ControllButton: View {
let systemIconName: String
let action: () -> Void
var body: some View {
Button(action: {
self.action()
}){
Image(systemName: systemIconName)
.font(.system(size: 35))
.foregroundColor(.white)
.buttonStyle(PlainButtonStyle())
}
.frame(width: 50,height: 50)
}
}
截图: image
解决方法
首先,欢迎杰瑞米。
您可以简单地使用 .overlay
修饰符:
ARViewContainer().edgesIgnoringSafeArea(.all)
.overlay(ControlView(showInfo: $showInfo).padding(),alignment: .topTrailing)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。