如何向 UIImage 或 UIImageView 或 UIView 添加外发光
我想向 UIImage
/UIImageView
/UIView
添加褪色阴影/外发光,但我不知道 Core Graphics
完全没有。
编辑: 请帮助!
I want to add a FADED shadow/outer glow to a UIImage
/UIImageView
/UIView
but I know no Core Graphics
at all.
Edit:
Please Help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
采用 Cirrostratus 概述的方法,保留其缓存副本,然后在拖动时应用变换来更改图像的大小和/或位置。
(警告,这不是功能/测试代码,但应该让您开始)
然后在您的方法中,在缩放时您会执行以下操作:
一定要看看苹果文档。一个好的起点是 Quartz 2D 编程指南< /a>.
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.
(warning, this is not functional/tested code, but should get you started)
Then in your method while scaling you would do something like:
Definitely take a look at the apple docs. A good starting place is the Quartz 2D Programming Guide.
你可以使用这个,简单快捷,这可以使用 uiview、unbutton 等:
如果你可以使用收音机,请添加以下内容:
You can use this, simple and fast, this works using uiview, unbutton, etc:
if, you can use radios, add this:
出于性能考虑,iPhone OS 不支持通常可以在 Cocoa 中使用的shadowColor、shadowOffset、shadowOpacity 和shadowRadius 属性。大多数人会多次复制他们想要发光的形状,每次都会降低不透明度并每次偏移一个像素以模拟发光的外观。如果您的辉光不需要很大,您就无法分辨出差异。
As a performance consideration, iPhone OS does not support the shadowColor, shadowOffset, shadowOpacity, and shadowRadius properties, which you could normally use in Cocoa. Most people duplicate the shape they want to glow several times with each time lowering the opacity and offsetting the shape one pixel at a time to simulate the look of a glow. If your glow does not need to be very big, you cannot tell the difference.