Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Take the approach outlined by Cirrostratus, keep a cached copy of it, and then apply a transform to change the size and/or position of the image while dragging.</p> <p>(warning, this is not functional/tested code, but should get you started)</p> <pre><code>-(UIImage*)addGlowToImage:(UIImage*)imageInput; { CGRect newSize = imageInput.bounds; CGImageRef theImage = imageInput.CGImage; // expand the size to handle the "glow" newSize.size.width += 6.0; newSize.size.height += 6.0; UIGraphicsBeginImageContext(newSize); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginTransparencyLayerWithRect(ctx, newSize, NULL); CGContextClearRect(ctx, newSize); // you can repeat this process to build glow. CGContextDrawImage(ctx, newSize, theImage); CGContextSetAlpha(ctx, 0.2); CGContextEndTransparencyLayer(ctx); // draw the original image into the context, offset to be centered; CGRect centerRect = inputImage.bounds; centerRect.origin.x += 3.0; centerRect.origin.y += 3.0; CGContextDrawImage(ctx, centerRect, theImage); result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return result; } </code></pre> <p>Then in your method while scaling you would do something like:</p> <pre><code>// assumes UIImage *cachedImage = [self addGlowToImage:origImage]; has been called already. // assumes ivars for scale exists CGRect newRect = cachedImage.bounds; newRect.size.width += scale; newRect.size.height += scale; [cachedImage drawInRect:newRect]; // image will be scaled to fill destination rectangle. </code></pre> <p>Definitely take a look at the apple docs. A good starting place is the <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html" rel="noreferrer">Quartz 2D Programming Guide</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload