简体   繁体   中英

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
}

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM