ios - Change the background color of a view in swiftUI
问题描述
I want to make a simple form and change the background color of a text field, but Xcode provide me .background(background: View)
, etc option but not .background(Color()
).
解决方案
Color
符合View
。因此,您可以像使用其他任何View
. 您的代码的问题是您cornerRadius
在background
修饰符中添加。它应该是这样的:
TextField("Title", text: .constant("text"))
.background(Color.red)
.cornerRadius(5)
推荐阅读
- haskell - “MonadReader (Foo m) m”导致函数依赖的无限类型
- mysql - Sql 在 wordpress 中的行为怪异
- r - 为什么使用并行计算包会使我的 R 代码运行速度变慢
- java - 在java中要求用户输入有效命令
- php - Twig_SimpleFunction 中的树枝递归函数
- ruby-on-rails - 复杂的左连接查询 ruby on rails
- sql - 规范化单表数据库
- java - 斯坦福 NLP,加载标记器模型时出错,同时从路径读取模型
- android - Robolectric 不支持 API 级别 27
- r - 不使用 DSN 时 R ODBC nanodbc 错误