ios - Constraints and SubLayers(CALayer) not updating -
i have created left border in superview
... var leftlayer: calayer? override public func awakefromnib() { super.awakefromnib() self.leftlayer = calayer() self.leftlayer?.bordercolor = uicolor.red.cgcolor self.leftlayer?.borderwidth = 1 self.layer.addsublayer(self.leftlayer!) ...
and in layoutsubviews try update border acording constraints:
... override public func layoutsubviews() { super.layoutsublayers(of: layer) leftlayer!.frame = cgrect(x: 0, y: 0, width: 1, height: self.frame.size.height) } ...
but sub calayers not following top calayer/uiviews constraints . have seen this, unable add layers superview.
do know how have sub calayer follow constraints of containing uiview?
override view's frame property adjust sub layers frame:
override var frame: cgrect { didset{ leftlayer!.frame = cgrect(x: 0, y: 0, width: 1, height: self.frame.size.height) } }
Comments
Post a Comment