title: Remove Dynamically created UIButton Subview
body: <p>I have applied a custombadge as a subview of a UIButton with the help of @Midhun MP in this question - <a href="https://stackoverflow.com/questions/19704755/adding-a-subview-to-uibutton">Adding a subview to UIButton</a>.</p>
  
  <p>All works great - but I'm now trying to remove the subview when the button is clicked.</p>
  
  <p>I've setup a method thats triggered via a click on one of the buttons </p>
  
  <pre><code>- (void)hide
  {
      //Hide Buttons
      _importantMsg.hidden = YES;
  
  
      [CustomBadge removeFromSuperview];
  
  }
  </code></pre>
  
  <p>But I'm struggling to hide the subview - I've tried - </p>
  
  <pre><code>[CustomBadge removeFromSuperview];
  </code></pre>
  
  <p>and</p>
  
  <pre><code>_MsgHeadBtn.subviews.hidden = YES;;
  </code></pre>
  
  <p>but i get unknown receiver errors - can anyone point me in thh right direction pls?</p>
  
  <p>errors for each try show in screenshot below - </p>
  
  <p><img src="https://i.stack.imgur.com/MKIq3.png" alt="enter image description here"></p>