ios – How one can improve Button hit take a look at faucet measurement by way of interplay contentShape?


I wish to improve the faucet goal for my Button with out affecting the structure. The button measurement ought to stay the identical (50pt) however ought to permit tapping outdoors of it (one other 50pt) to set off the button. I perceive the contentShape API ought to be capable to do that utilizing the interplay variety, nonetheless I can’t get it working when utilized to the Button nor its label. You need to faucet instantly within the label’s body, can’t faucet on the Textual content beneath nor above it. What’s the fitting means to do that?

VStack(spacing: 0) {
    Button {
        print("Tapped")
    } label: {
        Textual content("A")
            .body(width: 50, top: 50)
            .background(Colour.accentColor.opacity(0.2))
            .clipShape(.circle)
            .contentShape(.interplay, .rect(cornerRadius: 0).inset(by: -50))
    }
    .contentShape(.interplay, .rect(cornerRadius: 0).inset(by: -50))
        
    Textual content("Check")
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles