1.ForEach警告,逻辑不执行的: Non-constant range: argument must be an integer literal

改为
ForEach(0 ..< count, id:\.self) {
}

2.处理onTapGesture 点击空白区域无效的 自定义扩展onTapExpandArea,使用自定义的
private struct LBExpandAreaTap: ViewModifier {
func body(content: Content) -> some View {
ZStack {
Rectangle()
.foregroundColor(Color.white)
.contentShape(Rectangle())
content
}
}
}
extension View {
public func onTapExpandArea(tap: @escaping () -> ()) -> some View {
self.modifier(LBExpandAreaTap()).onTapGesture(perform: tap)
}
}
3.List间距的,去掉list内间距的.listStyle(.plain),去掉listItem间距的.listRowInsets(EdgeInsets())
List{
Section(header: Text("蓝牙设备").bold().foregroundColor(.black).font(.title).padding(.bottom,10)) {
listItemViews.listRowInsets(EdgeInsets())///去掉listItem的间距 靠边的
}
}.task {
self.bluetoothManager.initBluetoothManager()
}.onDisappear{
self.bluetoothManager.stopScanPeripherals()
}
///去掉内间距
// .listStyle(.plain)
///外间距
// .padding(.all,20)
// .onAppear{
// self.bluetoothManager.initBluetoothManager()
// }
网友评论