You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除SwiftUI Picker组件中的^标记?

移除SwiftUI Picker默认的下拉箭头(^标记)

针对你的代码,提供两种适配不同iOS版本的解决方案:

方案一:iOS 16+ 直接隐藏指示器

利用iOS 16新增的API,直接隐藏Picker菜单的默认箭头:

Button(action: {}) {
    ZStack {
        Picker("", selection: $month){
            ForEach(0..<months.count, id: \.self) { index in
                Text("\(months[index])")
            }
        }
        .accentColor(.black)
        .padding(.trailing, 30)
        .tag(3)
        .pickerStyle(.menu)
        .menuIndicatorVisibility(.hidden) // 隐藏默认箭头
        Image("bul_drop_down").position(x: 75, y: 26)
    }
}.buttonStyle(SelectBtnStyle(width: 100))

方案二:兼容iOS 15及以下,通过裁剪隐藏箭头

如果需要适配更低版本,可通过缩小Picker的显示范围并裁剪,把默认箭头隐藏:

Button(action: {}) {
    ZStack {
        Picker("", selection: $month){
            ForEach(0..<months.count, id: \.self) { index in
                Text("\(months[index])")
            }
        }
        .accentColor(.black)
        .padding(.trailing, 30)
        .tag(3)
        .frame(width: 80) // 限制宽度,裁剪掉右侧箭头区域
        .clipped()
        Image("bul_drop_down").position(x: 75, y: 26)
    }
}.buttonStyle(SelectBtnStyle(width: 100))

内容的提问来源于stack exchange,提问作者nickpury_hwang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 05:25:44