Create a glow around the UIView

I would like to draw a light stream around a UIView, which is approximately 5 pixels from the UIView itself.

Please, could you tell me how I could achieve this?

+6
objective-c iphone xcode ios4 quartz-graphics
source share
2 answers

Probably the easiest way is to create a shadow, but use a light color instead of a dark one. Shadow details can be found here: How to draw a shadow under a UIView? and here .

Something like this should make the ball roll:

- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 10, [UIColor whiteColor].CGColor); [super drawRect:rect]; CGContextRestoreGState(context); } 

Update: I just tried this. You will need to use this code to supervise the luminous view in order for it to work correctly.

+13
source share

The first thing I would like to try is to insert a UIView into a UIView that has a glow image. If the glow effect is just an image, then you create a UIView containing the glow image, which is 10 pixels higher and wider than the UIView environment. This will allow the use of 5 pixels of expansion on all 4 sides. You can do all this quickly and easily with Interface Builder.

If you want the glow effect to look really cool, considering that you are creating a collection of light images that, when viewed as a sequence, will show the appearance of the moving glow. You can then use this collection of images in a UIView and enable animation. All UIView controls have built-in animation support.

Hope this helps. Good luck.

+3
source share

All Articles