Stussa
Stussa

Reputation: 3415

Flash of Light Under Tap on iPhone

What is the best way to add a small flash of light under neath a touch on a photo (similar to how Facebook does it when tagging a photo)? I currently have a gesture recognizer setup and working but can't figure out how to add the basic light indicator under the finger:

- (void)tap:(UITapGestureRecognizer *)recognizer
{
    CGPoint point = [recognizer locationInView:self.photoImageView];

    // TODO: add flash
}

Upvotes: 1

Views: 263

Answers (2)

logancautrell
logancautrell

Reputation: 8772

There are a couple of ways to do this. The easiest is to create a custom image, load it into a UIImageView, place the UIImageView under the touch, and then use a simple animation to drop the opacity to 0 over a short period.

Upvotes: 1

mahboudz
mahboudz

Reputation: 39376

The easiest way to do this may be to animate the quick fade-in/fade-out of a UIImage that is a white gradient circle - one that is brightest white in the center and tapers to transparent as towards the edges. Place the UIImage where the tap is, with an opacity of 0, and do an animation that takes the opacity to 1 and then back to 0 in about 0.5 second.

The nice thing about using a UIImage is that you can easily swap in different images to see what works best.

Upvotes: 4

Related Questions