Add drop shadow to PNG using Cocoa

↘锁芯ラ 提交于 2019-12-05 17:33:13

Simplest way is to call CGContextSetShadow in your drawRect: before you draw the images.

- (void)drawRect:(CGRect)invalidRect
{
    CGContextRef c = UIGraphicsGetCurrentContext();
    CGContextSetShadow(c, CGSizeMake(5.0f, 5.0f), 5.0f);
    [myImage drawAtPoint:CGPointMake(50.0f, 50.0f)];
}

I found this category to be very useful: UIImage+Shadow.m

https://gist.github.com/kompozer/387210

I am not really a graphics person, but what about this: if you have a mask for these images, or if you can create one programatically, then you can probably use a blur function to add a shadow like effect.

Experiment in Photoshop/Acorn/Pixelmator?

Since you want shadows like they all have the same light source... it seems like you might actually be better off with an OpenGL view, that casts a light from above and the images would sit slightly above a flat plane to cast a shadow on. I'd look for 3D OpenGL frameworks that would let you add things pretty easily...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!