title: How can I Use Alpha Extension For All Object in swift?
body: <p>I have below code for changing the value of object like text,image , ... with Effect. and it work:</p>
  
  <pre><code>UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseOut, animations: {
                          self.lblCityTemp.alpha = 0.0
                          self.imgCityIcon.alpha = 0.0
                      }, completion: {
                          (finished: Bool) -&gt; Void in
  
                          //Once the label is completely invisible, set the text and fade it back in
                          self.imgCityIcon.image = UIImage(named: icon)
                          self.lblCityTemp.text = "\(temp)°"
  
                          // Fade in
                          UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseIn, animations: {
                              self.lblCityTemp.alpha = 1.0
                              self.imgCityIcon.alpha = 1.0
  
                          }, completion: nil)
                      })
  </code></pre>
  
  <p>Now I want make a extension of this code that I use for all my object that I write below code:</p>
  
  <pre><code>extension NSObject {
  
      func Fade (alphaOUT: Double,alphaIN: Double, input: Any) {
          UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseOut, animations: {
              self.alpha = CGFloat(alphaOUT)
          }, completion: {
              (finished: Bool) -&gt; Void in
  
              // Fade in
              UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseIn, animations: {
                  self.alpha = CGFloat(alphaIN)
  
              }, completion: nil)
          })
      }
  }
  </code></pre>
  
  <p>But I have error on self word and I do not know how can I set value for every object like label, imageView , ....</p>
  
  <p>How can I do this?
  Is the extension is best way or no?
  If no, so what is the best way?</p>