Git Product home page Git Product logo

swiftui-visual-effects's Introduction

SwiftUI Visual Effects


System materials in SwiftUI

View modifiers that wrap UIVisualEffectView and all of its associated objects, with environment integration for storing effect styles. Vibrancy effects will always use the current blur effect style for proper vibrancy-effect layering.

Adding and Styling a Blur Effect

YourView()
  // Add a blur effect.
  .blurEffect()
  // Style the blur effect.
  .blurEffectStyle(.systemChromeMaterial)

Adding and Styling a Vibrancy Effect

YourView()
  // Add a vibrancy effect.
  .vibrancyEffect()
  // Style the vibrancy effect.
  .vibrancyEffectStyle(.fill)

Adding and Styling Blur and Vibrancy Effects

ZStack {
  YourBackgroundContent()
    // Add a blur effect.
    .blurEffect()

  YourForegroundContent()
    // Add a vibrancy effect.
    .vibrancyEffect()
}
// Set the style for blur effects within this view.
.blurEffectStyle(.systemChromeMaterial)
// Set the style for vibrancy effects within this view.
.vibrancyEffectStyle(.fill)

Adding Blur and Vibrancy Effects Directly to a View

Adding both a blur and vibrancy effect directly to a view only displays the blur effect.

If you’d like to blur the view’s background content, while adding vibrancy to the view’s foreground content, use the .background() modifier, and pass BlurEffect() as its argument. Although BlurEffect may not be very Apple-like, it’s better than the .blurEffect() modifier implementation below.

YourView()
  .vibrancyEffect()
  .background(BlurEffect())

// as opposed to:

YourView()
  .vibrancyEffect()
  .background(
    Color.clear
      .blurEffect()
  )

swiftui-visual-effects's People

Contributors

lucasbrown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.