Vsibility mask on UIView with CAShapeLayer

169 views Asked by At

So what I need to do is skewed UIViews (UIImageView, UIButton etc..).

I figured I need CAShapeLayer with CGPath. So far so good. Then I need to assign this to myView.layer.mask. Its ok too. But what if my UIView resizes? Do I need to recalc/remake the mask or is there some place I can put this to occur automatically?

I can't KVO with Categories (Objc) or extensions (Swift) since I can't globally modify dealloc method.

1

There are 1 answers

0
Zdeněk Topič On BEST ANSWER

So I created a Swift subclass of UIView that will do the layer masking with didSet observer on bounds. It servers as container for subview/s that are supposed to be skewed.