Is the opacity and alpha the same thing for UIView [duplicate]

柔情痞子 提交于 2020-01-12 04:23:07

问题


I want to use animation to change UIView's color to make it fade, however, somehow i can't access and set opacity, but i can set alpha. I wonder if alpha and opacity are the same? Search on the web and I didnt find a good answer. Thanks a lot for your help!


回答1:


Actually "opacity" means "value of alpha-channel" of your UIView. When a view is fully opaque this means its alpha = 1, when a view is fully transparent (non-opaque) its alpha = 0.

As about properties of CALayer and UIView in Cocoa, yes, they provide the same functionality.




回答2:


Just try by yourself!

CALayer has opacity from 0 to 1, while UIView has alpha from 0 to 1. They have the same visual effect.




回答3:


Alpha affects everything drawn on the view.The background color's alpha affects the background color's transparency and anything else drawn on the view.i.e it brings about a frosty effect to whole view. Opacity means don't draw anything underneath, even if you are transparent, it just effects the current view.



来源:https://stackoverflow.com/questions/15381436/is-the-opacity-and-alpha-the-same-thing-for-uiview

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