如何在不使用旧UISegmentControl的情况下更改swiftUI中分段控件的半径
我试图在SwiftUI中更改段控制的半径。我只能改变外半径。有没有办法更改所选标记的半径如何在不使用旧UISegmentControl的情况下更改swiftUI中分段控件的半径,swift,uisegmentedcontrol,swiftui,Swift,Uisegmentedcontrol,Swiftui,我试图在SwiftUI中更改段控制的半径。我只能改变外半径。有没有办法更改所选标记的半径 struct ContentView: View { @State private var favoriteColor = 0 var colors = ["Red", "Green", "Blue"] var body: some View { VStack { Picker(selection: $favoriteColor, label
struct ContentView: View {
@State private var favoriteColor = 0
var colors = ["Red", "Green", "Blue"]
var body: some View {
VStack {
Picker(selection: $favoriteColor, label: Text("What is your favorite color?")) {
ForEach(0..<colors.count) { index in
Text(self.colors[index]).tag(index)
}
}.pickerStyle(SegmentedPickerStyle())
.cornerRadius(13). ////////////////////////////////--
Text("Value: \(colors[favoriteColor])")
}
}
}
struct ContentView:View{
@国家私有变量favoriteColor=0
变量颜色=[“红色”、“绿色”、“蓝色”]
var body:一些观点{
VStack{
选择器(选择:$favoriteColor,标签:Text(“您最喜欢的颜色是什么?”)){
ForEach(0..在这一点上,我认为没有办法修改所选标签的属性(例如形状)。我认为这要么是苹果公司的风格选择(因为他们希望标准控件看起来真正“标准”),要么就是他们还没有采取行动(SwiftUI在这一点上非常像1.0)
struct ContentView : View {
// 1.
@State private var selectorIndex = 0
@State private var numbers = ["One","Two","Three"]
var body: some View {
VStack {
// 2
Picker("Numbers", selection: $selectorIndex) {
ForEach(0 ..< numbers.count) { index in
Text(self.numbers[index]).tag(index)
}
}
.pickerStyle(SegmentedPickerStyle())
.introspectSegmentedControl{
segmentedControl in
segmentedControl.layer.cornerRadius = 0
segmentedControl.layer.borderColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0).cgColor
segmentedControl.layer.borderWidth = 1.0
segmentedControl.layer.masksToBounds = true
segmentedControl.clipsToBounds = true
}
// 3.
Text("Selected value is: \(numbers[selectorIndex])").padding()
}
}
}
struct ContentView:View{
// 1.
@状态专用变量selectorIndex=0
@国家私有变量编号=[“一”、“二”、“三”]
var body:一些观点{
VStack{
// 2
选择器(“数字”,选择:$selectorIndex){
ForEach(0..
当我投票时,我有两个请求。(1)你能发布足够的代码来复制你的问题吗?这会有帮助。(2)你能清楚地定义你所说的*“…更改所选标签的半径…”的意思吗让我们继续使用旧的-UIKit
-您能给我看一下您想要的东西和SwiftUI
对“所选标记”所做的不同吗?