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
view-layout
working-with-static-text
demo1
demo10
demo11
demo12
demo2
demo3
demo4
demo5
demo6
demo7
Demo
README.md
demo8
demo9
cheat-sheet.md
.gitattributes
.gitignore
LICENSE
README.md
idoc.chapters.yml
idoc.yml
package.json
renovate.json
克隆/下载
README.md 881 Bytes
一键复制 编辑 原始数据 按行查看 历史

如何使用 textCase() 使 TextField 大写或小写?

Updated for Xcode 13 New in macOS 12

SwiftUI 的 TextField 视图通常允许用户以他们希望的任何大小写文本,但是如果要控制,则可以使用 textCase() 修饰符强制使用大写或小写文本。

例如,这要求用户输入他们的名字,并在每个字母大写:

struct ContentView: View {
    @State private var name = "Paul"

    var body: some View {
        TextField("Shout your name at me", text: $name)
            .textFieldStyle(RoundedBorderTextFieldStyle())
            .textCase(.uppercase)
            .padding(.horizontal)
    }
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Swift
1
https://gitee.com/jaywcjlove/swiftui-example.git
git@gitee.com:jaywcjlove/swiftui-example.git
jaywcjlove
swiftui-example
swiftui-example
main

搜索帮助