How to add bottom shadow to table cell with dynamic height?
I am about to implement bottom shadow for table cells. However my table cells have dynamic heights and each cell can be toggled to expand or shrink. I would like to have the bottom sha开发者_开发问答dow anchored to the bottom of each cell.
My question is, if I generate the shadow using BPath in CALayer, how can I anchor the layer to the bottom of a view?
If you are using iOS 3.2 or later, you can use the shadow-specific properties in CALayer - shadowColor
, shadowOffset
, shadowOpacity
, shadowPath
and shadowRadius
.
[cell.layer setShadowOpacity:0.4];
You will have to manually adjust the shadow layer pre-iOS 3.2 and there is no automatic way in iOS to anchor it to the bottom. What you were looking for was CAConstraintLayoutManager
which is available in OSX but not in iOS.
精彩评论