swift - Set scrollview size and position by code -
i've added scrollview in main.storyboard , made same size view , set backgroundcolor blue. i'm having troubles autolayout i'm trying deactivate constraints code (succeeded) , set frame position , size following code inside viewdidload()
nslayoutconstraint.deactivateconstraints(self.view.constraints()) self.scrollview.frame = cgrectmake(0.0, 100.0, 200.0, 200.0) self.scrollview.backgroundcolor = (uicolor.redcolor()) when run code colour changes red (so i've got going me, nice) scrollview doesn't change position or size. right syntax this?
this work if set frame in viewdidlayoutsubviews():
override func viewdidlayoutsubviews() { super.viewdidlayoutsubviews() self.scrollview.frame = cgrect(x: 0.0, y: 100.0, width: 200.0, height: 200.0) } trying in viewdidload() not work because scrollview not yet in view hierarchy @ point.
note deactivating constraints view , not subviews in code snippet. may not intended.
also note i'm not endorsing way fix constraint problems. ;-)
Comments
Post a Comment