Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SwiftUI使用SegmentedPickerStyle在选择器内自定义字体大小_Swiftui_Font Size_Picker - Fatal编程技术网

SwiftUI使用SegmentedPickerStyle在选择器内自定义字体大小

SwiftUI使用SegmentedPickerStyle在选择器内自定义字体大小,swiftui,font-size,picker,Swiftui,Font Size,Picker,我试图自定义选择器中两个标记的字体大小。我使用的是SegmentedPickerStyle,我希望PickerFont大小与我在表单上使用的其他标题/字符串的文本大小相匹配。其他字体使用.font.headline var body: some View { NavigationView { ScrollView { VStack(alignment: .leading){ Group { Picker("

我试图自定义选择器中两个标记的字体大小。我使用的是SegmentedPickerStyle,我希望PickerFont大小与我在表单上使用的其他标题/字符串的文本大小相匹配。其他字体使用.font.headline

var body: some View {
NavigationView {
    ScrollView {
        VStack(alignment: .leading){
            Group {
                Picker("", selection: $form.nameType) {
                    Text("First/Last name \(form.nameType == 0 ? "*" : "")").tag(0)
                    Text("Company name \(form.nameType == 1 ? "*" : "")").tag(1)
                    }
                    .pickerStyle(SegmentedPickerStyle())    
                }
            }
        }
    }
}

通过添加以下内容,您可以自定义分段控制器的字体:

init() {
        UISegmentedControl.appearance().setTitleTextAttributes(
            [
                .font: UIFont.systemFont(ofSize: 18),
            ], for: .normal)
    }

通过添加以下内容,您可以自定义分段控制器的字体:

init() {
        UISegmentedControl.appearance().setTitleTextAttributes(
            [
                .font: UIFont.systemFont(ofSize: 18),
            ], for: .normal)
    }