How to move a UIView programmatically in Swift -


the issue move "infoview" (uiview) programmatically in swift.

the following constraints exist in storyboard (see image):

enter image description here

now, move "infoview" inside "myview" or down.

i tried:

@iboutlet weak var infotextlabel: uilabel! @iboutlet weak var infotextlabelview: uiview!  // set infotextlabel color self.infotextlabel.textcolor = uicolor.blackcolor() // set infotextlabel text self.infotextlabel.text = "hello" // unhide infotextlabel self.infotextlabel.hidden = false  // moving in y-direction, tried - not work !!!!!!! self.infotextlabelview.frame.origin.y += 200 

could autolayout-constraints play role. how overcome programmatically. or frame.origin.y method wrong 1 ??

appreciate on !

when using constraints, never want set view's frame directly. instead, reconfigure constraints , let auto layout engine set view's frame you. create iboutlet in view controller store reference "center y alignment constraint". make sure connect in storyboard or xib.

@iboutlet var yconstraint: nslayoutconstraint 

then can set constraint's constant property offset y position (positive number move down, negative moves up).

yconstraint.constant = 200 

this move view 200 points down.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -