如何使用Quartz 2D将阴影添加到UIImage或UIImageView? [英] How to use Quartz 2D to add drop shadow to an UIImage or UIImageView?
本文介绍了如何使用Quartz 2D将阴影添加到UIImage或UIImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Quartz 2D将阴影添加到 UIImage
或 UIImageView
?
How do I use Quartz 2D to add drop shadow to an UIImage
or UIImageView
?
任何代码示例?
推荐答案
imageView.layer.shadowColor = [UIColor blackColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(0, 1);
imageView.layer.shadowOpacity = 1;
imageView.layer.shadowRadius = 1.0;
不要忘记 #import< QuartzCore / QuartzCore.h>
Don't forget to #import <QuartzCore/QuartzCore.h>
in your implementation.
编辑:
添加@Luke的评论:
Adding in @Luke's comment:
只是有点困难,可能会节省一些其他人一段时间,确保你没有设置<$ c $ <> code>至在您的视图中显示
,否则阴影将不会
Just a little gotcha that might save some other people some time make sure you have not set layer.masksToBounds
to YES
on your view otherwise the shadow will not appear.
这篇关于如何使用Quartz 2D将阴影添加到UIImage或UIImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文