# Value of type 'CustomButton' has no member 'touchDown'

**URL:** <https://forums.kodeco.com/t/value-of-type-custombutton-has-no-member-touchdown/19951>\
**Category:** Swift\
**Created:** [September 19, 2016, 7:51am UTC](https://forums.kodeco.com/t/value-of-type-custombutton-has-no-member-touchdown/19951 "2016-09-19T07:51:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vimipatel](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/vimipatel/32/83106_2.png) [@vimipatel](https://forums.kodeco.com/u/vimipatel)\
**Post date:** [September 19, 2016, 7:51am UTC](https://forums.kodeco.com/t/value-of-type-custombutton-has-no-member-touchdown/19951/1 "2016-09-19T07:51:30Z")

</div>

I have created custom button class and override all touches methods. It works fine in swift 2 and Xcode 7.3.1. But when I open same app in Xcode 8.0, it will show errors :

> Value of type ‘CustomButton’ has no member ‘touchDown’  
> Value of type ‘CustomButton’ has no member ‘touchUpInside’  
> Value of type ‘CustomButton’ has no member ‘touchDragExit’  
> Value of type ‘CustomButton’ has no member ‘touchDragEnter’  
> Value of type ‘CustomButton’ has no member ‘touchCancel’

Here is my code :

```
import UIKit

@IBDesignable
@objc public class CustomButton: UIButton {

    private func addTargets() {

        //------ add target -------

         self.addTarget(self, action: #selector(self.touchDown(_:)), for: UIControlEvents.TouchDown)
         self.addTarget(self, action: #selector(self.touchUpInside(_:)), for: UIControlEvents.TouchUpInside)
         self.addTarget(self, action: #selector(self.touchDragExit(_:)), for: UIControlEvents.TouchDragExit)
         self.addTarget(self, action: #selector(self.touchDragEnter(_:)), for: UIControlEvents.TouchDragEnter)
         self.addTarget(self, action: #selector(self.touchCancel(_:)), for: UIControlEvents.TouchCancel)
    }

    func touchDown(sender: CustomButton) {
       self.layer.opacity = 0.4
    }

    func touchUpInside(sender: CustomButton) {
       self.layer.opacity = 1.0
    }

    func touchDragExit(sender: CustomButton) {
       self.layer.opacity = 1.0
    }

    func touchDragEnter(sender: CustomButton) {
       self.layer.opacity = 0.4
    }

    func touchCancel(sender: CustomButton) {
        self.layer.opacity = 1.0
    }
}

```

If anyone have any solution, please let me know. 😔

---

<div class="post-metadata">

**Author:** ![aeberbach](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aeberbach/32/81494_2.png) [@aeberbach](https://forums.kodeco.com/u/aeberbach)\
**Post date:** [September 20, 2016, 1:29am UTC](https://forums.kodeco.com/t/value-of-type-custombutton-has-no-member-touchdown/19951/2 "2016-09-20T01:29:16Z")

</div>

This works:

```
    @objc func touchDown(sender: CustomButton) {
        self.layer.opacity = 0.4
    }
    /*...*/
    func addTargets() {
        
        //------ add target -------
        self.addTarget(self, action: #selector(self.touchDown(sender:)), for: .touchDown)

```

Looks like making the actions @objc gives visibility, and autocomplete now offers a slightly different style for #selector. Also, note .`touchDown` now begins with ‘t’ not ‘T’.
