3 SwiftUI tiling black and white patterns.
5 This project contains `Patterns`, which are built out of `Tiles` with a given
8 It also includes a `TilePicker` that can be used to control the selected
11 ## Available Tile Designs
13 The `TileDesign` enum contains the following patterns (shown in the image from
14 top left to bottom right)
16 ![Image showing the included patterns]
34 The `Pattern` view will tile the selected design in its frame. It has the
37 * `design: TileDesign`: **required, @Binding**, which design to tile the frame with.
38 * `pixelSize: CGFloat`: **defaults to 2.0**, the size of a pixel in the tile.
39 * `foregroundColor: Color`: **defaults to `Color.black`**, the foreground color.
40 * `backgroundColor: Color`: **defaults to `Color.white`**, the background color.
43 // Pattern using default settings
44 Pattern(design: .constant(TileDesign.shadowGrid))
46 // Pattern using overrides
47 Pattern(design: $tileDesign, pixelSize: 4.0, foregroundColor: .pink, backgroundColor: .cyan)
50 ## Using the PatternPicker
52 The pattern picker view is intended to be used when you want to allow users to
53 change the design of the pattern.
55 * `selectedDesign: TileDesign`: **required, @Binding**, the current selected
57 * `selectedColor: Color`: **defaults to `Color.accentColor`**, the color of the
58 border around the selected tile design.
60 It also has `pixelSize`, `foregroundColor`, and `backgroundColor` with the
61 same effect as `Pattern` mentioned above
65 @State var design: TileDesign = .brick
66 @State var shouldShowPatternPicker = false
70 Pattern(design: $pattern)
71 .frame(width: 32.0).border(.black)
73 shouldShowPatternPicker = !shouldShowPatternPicker;
75 .popover(isPresented: $shouldShowPatternPicker) {
76 PatternPicker(selectedDesign: $design)
78 .onChange(of: pattern) { _ in
79 shouldShowPatternPicker = false;
83 ## Supported Platforms