Glass effects UIView

2019-04-13 14:32发布

I would like to know how it is possible to add a glass effect on a UIView

I would like something like this effects on the gray translucent view you can see here :

enter image description here

Thanks

4条回答
Anthone
2楼-- · 2019-04-13 15:15

There's a pretty cool Mac app called PaintCode, that allows you to create your glossy/glass effects in a similar way to Photoshop, say, but then generates the code you can add you your app. They give some examples here: http://www.paintcodeapp.com/examples.html

查看更多
何必那么认真
3楼-- · 2019-04-13 15:15

There is no trivial way to achieve this with a UIView, but of course it can be done, in the way that all graphics work can be done: Setup a drawing context and draw your effect using CoreGraphics in your views drawRect method.

If you're curious, I recommend you take a look at an application called Opacity. It is a simple graphics editor for Mac OS - and allows you to work on a visual canvas and apply effects, including, amongst others, a 'glass' filter. The distinguishing feature of this app is that it will generate backing Quartz code for what you've designed visually with its GUI.

The code it generates may or may not be sufficient for what you're seeking, but I use it routinely to generate rough drawing code that I can then look at as a basis to put together my own drawing code.

I have no affiliation with this product beyond the fact that I use it.

查看更多
三岁会撩人
4楼-- · 2019-04-13 15:21

I guess you need a glossy effect in your UIView. This can be achieved by setting the alpha mask of your UIView and adjusting the backgroundcolor to a little darker in the drawrect method of your UIView. If this doesnt satisfy your needs, you can go for a more comprehensive solution outlined by Matt Galagher

查看更多
小情绪 Triste *
5楼-- · 2019-04-13 15:27

There's nothing like glass effect in UIView .All you can do is set the opacity of the view between 0 and 1.Also the view shown above has fine set of images which makes it seem like your "Glass Effect".

Well If you what your UIView to be "shiny and elegant" , you can do it in two ways :-

1>You can simply have effects in images created with photoshop as it will decrease the overhead of doing the same with programming.

2>you can have it using core-Graphics library provided by apple then you might have to get into a more complex world of drawing and see the Tutorial to get Gloss Effect

Glossy Buttons By Ray wendelich

Another Tutorial on Glossy button

查看更多
登录 后发表回答