How to highlight a UIButton subclass?

后端 未结 2 405
予麋鹿
予麋鹿 2021-01-29 01:33

I have a subclass of UIButton where I overwrite drawRect for a custom looking button.

But now the cell doesn\'t highlight.

How can I f

相关标签:
2条回答
  • 2021-01-29 01:49

    i think you can deal with the highlight problem with these methods below

    - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
    - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
    - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;
    - (void)cancelTrackingWithEvent:(UIEvent *)event;
    

    you can change the color or the image in these method

    0 讨论(0)
  • 2021-01-29 01:52

    subclassing UIButton does not make sense because it's a kind of assembly/cluster class.

    I had best experience creating own buttons when subclassing UIControl and add some custom behavior.

    Check also this (you should not subclass UIButton).

    Then also check how you highlight UIControl subclass.

    0 讨论(0)
提交回复
热议问题