有没有办法向左和向右滑动表格行?我还没有找到适用于新框架 SwiftUI 的东西,所以也许没有机会为此使用 SwiftUI?我需要删除行并使用自定义滑动
我无法在SwiftUI中更改TabBar颜色。我尝试使用TabbedView,图像/文本和堆栈。什么都不适合我。
使用.foregroundColor不起作用。
TabbedView(selection: $selection){
TextView()
.tag(0)
.tabItemLabel(
VStack {
Image("Calendar")
.foregroundColor(.red)
Text("Appointments")
.foregroundColor(.red)
}
).foregroundColor(.red)
}.foregroundColor(.red)
Run Code Online (Sandbox Code Playgroud) 如何在SwiftUI中使用自定义滑动动作?
我试图使用UIKit框架使它们在SwiftUI中工作。但这对我不起作用。
import SwiftUI
import UIKit
init() {
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let important = importantAction(at: indexPath)
return UISwipeActionsConfiguration(actions: [important])
}
func importantAction(at indexPath: IndexPath) -> UIContextualAction {
let action = UIContextualAction(style: .normal, title: "Important") { (action, view, completion) in
print("HI")
}
action.backgroundColor = UIColor(hue: 0.0861, saturation: 0.76, brightness: 0.94, alpha: 1.0) /* #f19938 */
action.image = UIImage(named: "pencil")
return action
}
}
struct TestView: View {
NavigationView {
List {
ForEach(appointmentsViewModel.appointments.identified(by: \.id)) …Run Code Online (Sandbox Code Playgroud) 我试图在我的 NavigationLink 内部创建一个 NavigationLink 列表作为 DetailView。可悲的是,我遇到了奇怪的 UI 错误。这是代码:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink("label", destination: DetailView())
}
}
}
}
struct DetailView : View {
var body: some View {
NavigationView {
List {
NavigationLink("label", destination: Text("detail"))
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
2020-01-20 00:30:04.302351+0100 Test[14029:1128128] [Assert] UIScrollView does not support multiple observers implementing
_observeScrollView:willEndDraggingWithVelocity:targetContentOffset:unclampedOriginalTarget:.
Scroll view <_TtC7SwiftUIP33_BFB370BA5F1BADDC9D83021565761A4925UpdateCoalescingTableView:
0x7fbdc3865c00; baseClass = UITableView; frame = (0 0; 375 667); clipsToBounds = YES; …Run Code Online (Sandbox Code Playgroud)