Is there an way to make an invisible UIButton that will still “be there” and catch touch events for my UIImageView?

后端 未结 11 2049
悲哀的现实
悲哀的现实 2020-12-25 11:41

I thought to be clever and just put an transparent UIButton over an UIImageView with the exact frame size, so that I can wire it up easily with any event I like, for example

11条回答
  •  鱼传尺愫
    2020-12-25 12:39

    You should be able to set the button's 'Type' to Custom in Interface Builder, and it will not display any text or graphical elements over the UIImageView. This way, you don't need to adjust the alpha. If the view is built from code, use:

    button = [UIButton buttonWithType:UIButtonTypeCustom];
    

提交回复
热议问题