title: Error when using Binding in a Toggle Button: "Could not cast value of type 'CALayer' to 'SwiftUI.MaskLayer"
body: <p>I have a FeedbackView in SwiftUI that contains a couple of custom ToggleButtons. I have used these toggle buttons all throughout my App for a few months. The FeedbackView is new and is used in a couple of places in my App. When using the FeedbackView in one place in my App, complicated View with many components, the App crashes with an unhelpful stack trace and the error: &quot;Could not cast value of type 'CALayer' (0x7fff87efafe0) to 'SwiftUI.MaskLayer&quot;.</p>
  <p>Everything was working until I hooked up the binding for the selection state. I've never seen this error before and can't find any reference to it anywhere. Does anyone have any ideas on what it could be?</p>
  <p>I've included some code, but I don't expect anyone to find the issue based upon it, more hoping someone has come across the error before and can get give me an idea on what can cause it.</p>
  <p>Cut down version of FeedbackWidgetView</p>
  <pre><code>struct FeedbackWidgetView: View {
  
  @State var positiveSelected : Bool = false
  @State var negativeSelected : Bool = false
  
  var body: some View {
      ZStack {                    
          if question.positiveButtonLabel != nil {
              ToggleButton(title: question.positiveButtonLabel!,
                           borderColor: .buttonBorderSecondary,
                           isSelected: $positiveSelected)
          }
      }
  }
  </code></pre>
  <p>}</p>
  <p>ToggleButton:</p>
  <pre><code>struct ToggleButton: View {
  
      var title : String
      var iconName : String? // SF Symbol Name
      var primaryColor : Color?
      var borderColor : Color?
  
      var unselectedStyle : ButtonLabel.Style = .primary
      var selectedStyle : ButtonLabel.Style = .primarySelected
  
      var action : ((String) -&gt; Void)?
  
      @Binding var selected : Bool
  
      init(title: String,
           iconName: String?=nil,
           primaryColor: Color?=nil,
           borderColor: Color?=nil,
           unselectedStyle: ButtonLabel.Style = .primary,
           selectedStyle: ButtonLabel.Style = .primarySelected,
           isSelected: Binding&lt;Bool&gt; = .constant(false),
           action: ((String) -&gt; Void)?=nil) {
      
          self.title = title
          self.iconName = iconName
          self.primaryColor = primaryColor
          self.borderColor = borderColor
          self.unselectedStyle = unselectedStyle
          self.selectedStyle = selectedStyle
          self._selected = isSelected
          self.action = action
      }
  
      var body : some View {
          Button(action: {
              self.selected.toggle()
              self.action?(self.title)
          }) {
              ButtonLabel(title: title,
                          iconName: iconName,
                          primaryColor: primaryColor,
                          borderColor: borderColor,
                          style: selected ? selectedStyle : unselectedStyle)
                   .padding(1.0)
          }
      }
  }
  </code></pre>
  <p>Stack Trace:
  <a href="https://i.stack.imgur.com/v3TLJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v3TLJ.jpg" alt="Stack Trace Main Thread" /></a></p>