I have a UILabel
and I would like to make it react to a touch. I tried putting a button on top of the label, thanks to this I could interact with the button. However, the button cannot be fully transparent, right? I could set an alpha of the button to 0,02, but it is still visible on by background. How to solve this? Maybe I could set the properties in some other way to make them fully invisible? Or is there some other solution?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Algorithm for maximizing coverage of rectangular a
- Open iOS 11 Files app via URL Scheme or some other
- Is there a way to hide the new HTML5 spinbox contr
In Swift:
Get your click in Action :
I usually do this:
I don't know if it works with labels, but then i just make a transparent UIView with the same rect and put it on top.
Okay, i checked, it only works in UIView, but then, do this:
And put "tapView" in the addGestureRecognizer-method.
First, why not just use a button and set the button title to the label's contents?
If you can't/don't want to do that, you can also set
userInteractionEnabled = YES
on the label and then add a gesture recognizer to the label.