---
title: colorInvert()
framework: swiftui
role: symbol
role_heading: Instance Method
path: swiftui/view/colorinvert()
---

# colorInvert()

Inverts the colors in this view.

## Declaration

```swift
nonisolated func colorInvert() -> some View

```

## Return Value

Return Value A view that inverts its colors.

## Discussion

Discussion The colorInvert() modifier inverts all of the colors in a view so that each color displays as its complementary color. For example, blue converts to yellow, and white converts to black. In the example below, two red squares each have an interior green circle. The inverted square shows the effect of the square’s colors: complimentary colors for red and green — teal and purple. struct InnerCircleView: View {     var body: some View {         Circle()             .fill(Color.green)             .frame(width: 40, height: 40, alignment: .center)     } }

struct ColorInvert: View {     var body: some View {         HStack {             Color.red.frame(width: 100, height: 100, alignment: .center)                 .overlay(InnerCircleView(), alignment: .center)                 .overlay(Text("Normal")                              .font(.callout),                          alignment: .bottom)                 .border(Color.gray)

Spacer()

Color.red.frame(width: 100, height: 100, alignment: .center)                 .overlay(InnerCircleView(), alignment: .center)                 .colorInvert()                 .overlay(Text("Inverted")                              .font(.callout),                          alignment: .bottom)                 .border(Color.gray)         }         .padding(50)     } }

## See Also

### Transforming colors

- [brightness(_:)](swiftui/view/brightness(_:).md)
- [contrast(_:)](swiftui/view/contrast(_:).md)
- [colorMultiply(_:)](swiftui/view/colormultiply(_:).md)
- [saturation(_:)](swiftui/view/saturation(_:).md)
- [grayscale(_:)](swiftui/view/grayscale(_:).md)
- [hueRotation(_:)](swiftui/view/huerotation(_:).md)
- [luminanceToAlpha()](swiftui/view/luminancetoalpha().md)
- [materialActiveAppearance(_:)](swiftui/view/materialactiveappearance(_:).md)
- [materialActiveAppearance](swiftui/environmentvalues/materialactiveappearance.md)
- [MaterialActiveAppearance](swiftui/materialactiveappearance.md)
