UIButton default tap fade animation missing in UITableViewController custom cell

后端 未结 6 934
后悔当初
后悔当初 2021-02-08 08:41

I have a custom cell with a few UIButtons in it. I have created Target Actions like so on the buttons:

[cell.customLocationButton addTarget:self action:@selector         


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-08 09:12

    you probably initialized the button like this:

    let button = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: , height: )
    

    try to do it like this:

    let button = UIButton.init(type: .system)
    button.frame = CGRect.init(x: 0, y: 0, width: , height: )
    

    The "fade" animation on tap, comes with system style, after init the button you can customize it.

提交回复
热议问题