2 Star 23 Fork 10

小弟调调/swiftui-example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
.idoc
assets
example
accessibility
advanced-state
alerts-and-menus
animation
appendix-a
composing-views
containers
cross-platform
data
drawing
forms
images-shapes-media
introduction
lists
presenting-views
quick-start
responding-to-events
stacks-grids-scrollviews
taps-and-gestures
tooling
transforming-views
user-interface-controls
demo1
demo10
demo11
demo12
demo13
demo14
demo15
demo16
demo17
demo18
demo19
demo2
demo20
demo21
demo22
demo23
demo24
demo25
demo26
demo27
demo28
Demo
imgs
README.md
demo3
demo4
demo5
demo6
demo7
demo8
demo9
view-layout
working-with-static-text
cheat-sheet.md
.gitattributes
.gitignore
LICENSE
README.md
idoc.chapters.yml
idoc.yml
package.json
renovate.json
克隆/下载
README.md 1.24 KB
一键复制 编辑 原始数据 按行查看 历史

如何获得突出的边框按钮?

Updated for Xcode 13.0 New in iOS 15

SwiftUI 具有专用的 .bordered 按钮样式,模仿了许多 Apple 应用程序中使用的常见外观和感觉。 在最基本的形式中,它看起来像这样:

Button("Buy: $0.99") {
    print("Buying…")
}
.buttonStyle(.bordered)

但是,对于应该在屏幕上真正突出的按钮,您可能希望使用 borderedProminent 选项使它们的颜色更浓:

Button("Buy: $0.99") {
    print("Buying for $0.99")
}
.buttonStyle(.borderedProminent)

重要提示:有很多突出的按钮并不是好的 UI 实践。

您可以使用 tint() 自定义这些按钮的颜色:

Button("Submit") {
    print("Submitting…")
}
.tint(.indigo)
.buttonStyle(.borderedProminent)

或者通过将角色附加到按钮:

Button("Delete", role: .destructive) {
    print("Deleting…")
}
.buttonStyle(.borderedProminent)

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Swift
1
https://gitee.com/jaywcjlove/swiftui-example.git
git@gitee.com:jaywcjlove/swiftui-example.git
jaywcjlove
swiftui-example
swiftui-example
main

搜索帮助