【问题标题】:SwiftUI Image-Button without BorderSwiftUI 无边框图像按钮
【发布时间】:2021-04-28 08:59:43
【问题描述】:

我正在尝试在 **SwiftUI** 中创建一个可点击的 **Image**,在浏览了几个网页后,我发现了以下代码:
Button(action: {
            toggleWidth()
        }) {
            Image(systemName: "chevron.right")
                .resizable()
                .aspectRatio(contentMode: .fill)
                .frame(width: 20, height: 20)
                .cornerRadius(40)
                .buttonStyle(BorderlessButtonStyle())
        }

创建以下输出: Buttons

无论我想做什么,我似乎都无法消除按钮本身的填充。 为了显示图像,我缺少什么按钮?

【问题讨论】:

    标签: image button swiftui


    【解决方案1】:

    不是 100% 确定你在问什么,但也许你可以试试这个:

    Button(action: {
        toggleWidth()
    }) {
        Image(systemName: "chevron.right")
            .resizable()
            .aspectRatio(contentMode: .fill)
            .frame(width: 20, height: 20)
            .cornerRadius(40)
    }.buttonStyle(BorderlessButtonStyle())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-30
      • 2010-12-05
      • 1970-01-01
      • 2021-09-11
      相关资源
      最近更新 更多