Presently, I’ve the next SwiftUI widget.
struct TodoWidgetEntryView : View {
var entry: Supplier.Entry
let todoItems: [TodoItem] = DataManager().todoItems
var physique: some View {
VStack(alignment: .main, spacing: 1) {
ForEach(0..<todoItems.depend, id: .self) { index in
Button(intent: TodoIntent(merchandise: todoItems[index].taskName)) {
Label(todoItems[index].taskName, systemImage: "circle(todoItems[index].isCompleted ? ".fill" : "")")
.body(maxWidth: .infinity, alignment: .main).lineLimit(1)
}
.foregroundColor(.black) // label coloration
}
Spacer(minLength: 0)
}.background(SwiftUI.Colour.fromInt(0xfff7ce46)) // yellow coloration
}
}
It seems as following
What I’m anticipating, is utilizing semi-transparent white background for the interactive button.
I want it should look much like this foremost app display, applied in UIKit’s UICollectionViewCell
.
The round-cornered, semi-transparent background is applied utilizing the next code
contextView.layer.cornerRadius = 22
contextView.layer.masksToBounds = true
contextView.backgroundColor = UIColor(purple: 1.0, inexperienced: 1.0, blue: 1.0, alpha: 0.5)
I alter the SwiftUI code to
struct TodoWidgetEntryView : View {
var entry: Supplier.Entry
let todoItems: [TodoItem] = DataManager().todoItems
var physique: some View {
VStack(alignment: .main, spacing: 1) {
ForEach(0..<todoItems.depend, id: .self) { index in
Button(intent: TodoIntent(merchandise: todoItems[index].taskName)) {
Label(todoItems[index].taskName, systemImage: "circle(todoItems[index].isCompleted ? ".fill" : "")")
.body(maxWidth: .infinity, alignment: .main).lineLimit(1)
}
.foregroundColor(.black) // label coloration
.background(SwiftUI.Colour.fromInt(0x7fffffff)) // semi-transparent white coloration
}
Spacer(minLength: 0)
}.background(SwiftUI.Colour.fromInt(0xfff7ce46)) // yellow coloration
}
}
Nevertheless, I’m not getting the specified outcome.
Might I do know, find out how to change background coloration of Button with Customized Label view, in SwiftUI widget?