我正在尝试更改列表中的行颜色。
# frame for the two buttons
top_inner_frame = tk.Frame(top_frame)
top_inner_frame.grid(row=1, column=0, columnspan=width)
button_1 = tk.Button(top_inner_frame, text='Move to Center Position')
button_1.pack(size="left", pady=pady_5)
button_2 = tk.Button(top_inner_frame, text='Move to Last Position')
button_2.pack(size="left", pady=pady_5)
输出:-
我想实现:-
有人可以向我解释如何更改整行颜色。我已经尝试通过上面的方法实现,但还没有结果。
任何帮助将不胜感激。
提前致谢。
答案 0 :(得分:1)
使用listRowBackground
var body: some View {
VStack{
List {
ForEach(0...15, id: \.self, content: row(for:)).background(Color.red).listRowBackground(Color.red)
}
}
}