title: Custom Clear Button
body: <p>I want to create custom clear button on UITextField, that is to use  rightView and put image there, the problem is attaching the original clear button event to that custom rightView.</p>
  
  <p>In Objective-C i can do that this way:</p>
  
  <pre><code>SEL clearButtonSelector = NSSelectorFromString(@"clearButton");
  // Reference clearButton getter
  IMP clearButtonImplementation = [self methodForSelector:clearButtonSelector];
  // Create function pointer that returns UIButton from implementation of method that contains clearButtonSelector
  UIButton * (* clearButtonFunctionPointer)(id, SEL) = (void *)clearButtonImplementation;
  // Set clearTextFieldButton reference to “clearButton” from clearButtonSelector
  UIButton *_clearTextFieldButton = clearButtonFunctionPointer(self, clearButtonSelector);
  [_clearTextFieldButton setImage:[UIImage imageNamed:@"icon_remove"] forState:UIControlStateNormal];
  self.hasClearButtonAsRightView = YES;
  </code></pre>
  
  <p>now how to convert this to Swift?
  or any ideas to workaround it?</p>