小编Gor*_*Cat的帖子

SwiftUI 选择器在 iOS16 中具有不选择的选项

我使用的 Picker 没有选择,在 iOS15 中它工作正常,但在 iOS16 中它有一个默认值,我如何删除这个默认值,我不需要在 Picker 行右侧显示文本当选择为零时。

struct ContentView: View {
    
    @State private var selection: String?
    let strengths = ["Mild", "Medium", "Mature"]
    
    var body: some View {
        NavigationView {
            List {
                Section {
                    Picker("Strength", selection: $selection) {
                        ForEach(strengths, id: \.self) {
                            Text($0).tag(Optional($0))
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在iOS15中,当selection为nil时,Picker行右侧不显示任何文本
在此输入图像描述

但在iOS 16中,相同的代码会导致不同的结果,当selection为nil时它有一个默认值 在此输入图像描述

swiftui swiftui-picker

9
推荐指数
1
解决办法
4913
查看次数

如何更改颤振应用程序键盘颜色?

在我的 flutter 中,我创建了一个 TextFormField,但它的键盘颜色在 iOS 中是黑色的,我想知道如何将其更改为白色。

颤振语言版本:>=2.2.2 <3.0.0

这是我关于 TextFormField 的代码:

TextFormField(
     style: TextStyle(
               fontSize: 14,
               color: Colors.black),
               autofocus: false,
               initialValue: 'initial value', 
               maxLines: 1,
               // onSaved: (String value) => _person = value,
               // obscureText: _isObscure,
               validator: (String value) {
                          if (value.isEmpty) {
                            return 'nononono';
                          }
                          return null;
                        },
               decoration: InputDecoration(
                          hintText: 'please make sure',
                          contentPadding: EdgeInsets.fromLTRB(15, 5, 15, 5),
               hintStyle: TextStyle(
                             color: Colors.grey,
                             fontSize: 12,
                             ),
               hasFloatingPlaceholder: false,
               // contentPadding: contentPadding,
               border: InputBorder.none,
               ),
),
Run Code Online (Sandbox Code Playgroud)

当我单击此 TextFormField 时

我得到的是:黑色键盘 …

keyboard colors flutter

6
推荐指数
2
解决办法
4034
查看次数

标签 统计

colors ×1

flutter ×1

keyboard ×1

swiftui ×1

swiftui-picker ×1