London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
-3.2 C
New York
Sunday, February 2, 2025

ios – iOS17 Interactive Widget – Easy methods to change background coloration of Button with Customized Label view, in SwiftUI widget?


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

enter image description here

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.

enter image description here

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.

enter image description here


Might I do know, find out how to change background coloration of Button with Customized Label view, in SwiftUI widget?

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com