问题
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