I have an UILabel. I want to glow the touch area in it. That is, when I click on a point in that UILabel, a small circular portion around the touch point should be presented with glowing effect. How can get this?
How to blink a touch area in UILabel iPhone?
407 views Asked by Confused At
3
There are 3 answers
0
On
Gesture recognizers are nice, but if you want to do something that starts when the finger touches, stops when the finger stops touching, and moves around with the finger in between, then it's hard to think of a good gesture recognizer for that. I think in that case you'd be better off just using touchesBegan, touchesMoved, and touchesEnded (don't forget touchesCancelled).
You can either put those methods on your view controller or subclass UILabel. Either way, set userInteractionEnabled = YES on the label.
As for how to graphically make that effect, I don't have any clever ideas for it at the moment.
Well you can do that by creating a
CALayer
or aCAGradientLayer
based on how you want your glow and add it as a sublayer to the label's layer at the location of the touch.For enabling the touch on
UILabel
, look atuserInteractionEnabled
property. You will need to set it toYES
.Then you will need to attach a
UITapGestureRecognizer
to the label for getting the tap. Once you have the touch location, add the custom glow layer as a subview to the label's layer in an invisible state. Animate the glow layer in and out. You might want to repeat a few times before removing the glow layer as a sublayer at completion.