Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    PFAS removal from industrial wastewater: How can activated carbon help?

    April 26, 2026

    A Practical Guide to Optimizing Hosting Deployment |

    April 26, 2026

    ios – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – Apply shadow only outside of a SwifUI transparent button?
    iOS Development

    ios – Apply shadow only outside of a SwifUI transparent button?

    big tee tech hubBy big tee tech hubApril 26, 2026091 Min Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – Apply shadow only outside of a SwifUI transparent button?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I have a SwiftUI button with a transparent background, a rounded border, and a shadow.

    The issue is that because the button is transparent, the shadow is visible both outside and inside the rounded rectangle. I would like the shadow to appear only outside the button, without bleeding into the transparent interior.

    transparent button image

    Here is a minimal example:

    import SwiftUI
    
    #Preview("StackOverflow Transparent Button Shadow") {
        let cornerRadius: CGFloat = 15
    
        Button {} label: {
            Text("Transparent button")
                .font(.system(size: 14, weight: .semibold))
                .foregroundStyle(.black)
                .padding(.horizontal, 16)
                .padding(.vertical, 8)
                .frame(height: 40, alignment: .center)
        }
        .background(.white)
        .clipShape(RoundedRectangle(cornerRadius: cornerRadius))
        .overlay {
            RoundedRectangle(cornerRadius: cornerRadius)
                .stroke(.red, lineWidth: 1)
                .shadow(
                    color: .blue,
                    radius: 2,
                    x: 0,
                    y: 0
                )
        }
        .padding(48)
        .background(Color.white)
    }
    

    This produces a glow around the border, but the shadow is also rendered inside the transparent area of the button.

    What I want is:

    • keep the button background transparent
    • keep the rounded border visible
    • apply the shadow/glow only outside the rounded rectangle
    • avoid any shadow appearing inside the button

    Is there a recommended SwiftUI way to mask or clip the shadow so that it only renders outside the shape?



    Source link

    Apply button iOS Shadow SwifUI Transparent
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – How to add pictures after keynote update with iPadOS 26.3.1?

    April 25, 2026

    ios – AVCaptureDevice.exposurePointOfInterest readback does not match set value on iPad Pro M4 / M3(UltraWide)and Gen2,3,4(TrueDepth) using resizeAspectFill

    April 25, 2026

    ios – Trying to build just after installing cordova and getting error after error

    April 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    PFAS removal from industrial wastewater: How can activated carbon help?

    April 26, 2026

    A Practical Guide to Optimizing Hosting Deployment |

    April 26, 2026

    ios – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026

    Wisconsin sues prediction market platforms over alleged illegal sports betting operations

    April 25, 2026
    Timer Code
    15 Second Timer for Articles
    20
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    PFAS removal from industrial wastewater: How can activated carbon help?

    April 26, 2026

    A Practical Guide to Optimizing Hosting Deployment |

    April 26, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.