如何在swiftUI控件中隐藏边框? [英] How to hide border in swiftUI control?

查看:146
本文介绍了如何在swiftUI控件中隐藏边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以隐藏SwiftUI选择器边框?它可能属于某个子层.

Is it possible to hide a SwiftUI picker border? Possibly it belongs t some sub-layer.

按照边界,我的意思是按照下面的图片显示的细灰色线.

By border, I mean the thin grey lines as per the image below.

import SwiftUI

struct TestView: View {

    @State private var selectedOption = "A"

    let options = ["A", "B", "C", "D", "E" ]

    var body: some View {

        VStack {
            Text(selectedOption)
            Picker(selection: self.$selectedOption, label: Text("Picker Name")) {
                ForEach(options, id: \.self) { option in
                    Text(option).rotationEffect(Angle(degrees: 90))
                }
            }
        .labelsHidden()
            .frame(width : 100, height : 30 )
        .rotationEffect(Angle(degrees: -90))
        }
    }
}

推荐答案

这些灰色的线是选择指示符",看来Apple对SwiftUI的使用与对UIKit UIPickerView的使用相同.总是显示.

These grey lines is 'selection indicator' and it seems that Apple has same approach for SwiftUI as for UIKit UIPickerView, ie. show always.

这是来自Apple UIPickerView文档:
"特殊注意事项
在iOS 7及更高版本上,您无法自定义选择器视图的选择指示器.选择指示符始终显示,因此将此属性设置为false无效."

Here is from Apple UIPickerView doc:
"Special Considerations
On iOS 7 and later you cannot customzie the picker view’s selection indicator. The selection indicator is always shown, so setting this property to false has no effect."

因此,对于Picker本身,没有任何官方"方式可以做到这一点.

So no "official" way to do this... with Picker itself.

这篇关于如何在swiftUI控件中隐藏边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆