OK, at this point I think I can say that I have found a solution to my original question. For the benefit of the net (since I couldn't Google any answer) here is what I did:
First I simply created a PNG file using Adobe. The PNG file contains a circle processed with 24 pixels of Gaussian blur on a transparent background. So basically I gave up trying to create a good looking glowing circle on the fly and manually drew one. This is the easy part.
The next part is to make the circle appear very fast, and then gradually fade out.
To do that I create a CALayer that contains the circle. This is the code from the awakeFromNib of my custom view:
Code:
const char* fileName = [[[NSBundle mainBundle] pathForResource:@"CircleBlur" ofType:@"png"] UTF8String];
CGDataProviderRef data_ref = CGDataProviderCreateWithFilename(fileName);
CGImageRef theImage = CGImageCreateWithPNGDataProvider(data_ref, NULL, NO, kCGRenderingIntentDefault);
touch_one_layer=[CALayer layer];
touch_one_layer.contents=theImage;
touch_one_layer.bounds=CGRectMake(0.0f,0.0f,90.0f,90.0f);
touch_one_layer.opacity=0;
[[self layer] addSublayer:touch_one_layer];
This creates a layer with the circle and makes that a sublayer of the view layer. The reason opacity is 0 is that the circle is usually invisible.
Now in the single touch event handler of the view controller, I have:
Code:
- (void)handleOneFingerTap:(UITapGestureRecognizer *)gestureRecognizer
{
CALayer *touch_one_layer = self.v.touch_one_layer;
[CATransaction begin];
[CATransaction setDisableActions:TRUE];
touch_one_layer.position=[gestureRecognizer locationInView:v];
[CATransaction commit];
[touch_one_layer addAnimation:touch_animation forKey:@"animateOpacity"];
touch_one_layer.opacity=0;
}
This makes the circle pop up, and then gradually fades out. "v" in the code is my custom view.
Now the final routine, the missing link, touch_animation. touch_animation is an instance of CABasicAnimation, defined as:
Code:
touch_animation=[CABasicAnimation animationWithKeyPath:@"opacity"];
touch_animation.duration=1.0;
touch_animation.repeatCount=0;
touch_animation.fromValue=[NSNumber numberWithFloat:1.0];
touch_animation.toValue=[NSNumber numberWithFloat:0.0];
touch_animation.removedOnCompletion=FALSE;
[touch_animation retain];
BTW, simply setting the opacity of the layer does not work reliably. I tried.