DotPattern Component in SwiftUI

Overview

DotPattern is a SwiftUI component for generating a dot pattern background. It provides customization options for setting the dot color, spacing between dots, brightness, and background color.

Preview

DotPattern Preview 1
DotPattern Preview 2

Installation

Include the DotPattern.swift file in your SwiftUI project. File Link

Properties

  • dotColor: Color (Default: Color.blue) - The color of the dots.
  • spacing: CGFloat (Default: 0) - Additional spacing between dots.
  • brightness: Double (Default: 1.0, Range: 0.0-1.0) - Opacity of the dots.
  • backgroundColor: Color (Default: Color.black) - The background color of the pattern.

Usage

Basic Usage

Here’s how you can use the DotPattern component with default parameters:

DotPattern()

Custom Usage

Here’s how you can use the DotPattern component with custom parameters:

DotPattern(dotColor: Color.black, spacing: 15, brightness: 0.8, backgroundColor: Color.white)