i have button @ x position when view loaded, , when button clicked want button go right under text field. don't want use static points (1,2) instead want use position of text field , shift button or down relative text field. appreciated.
@iboutlet weak var name: uitextfield! @iboutlet weak var log: uibutton! name.addtarget(self, action: "name:", forcontrolevents: uicontrolevents.editingdidbegin)
when text field clicked, want button move below name text field. nothing happens when click text field.
func name(sender: uitextfield){ var y: int = int(name.frame.origin.y) var x: int = int(name.frame.origin.x) log.frame = cgrect(x: x, y: y - 50, width: 157, height: 40) }
i create @iboutlet
nslayoutconstraint
links center of button center of text field. in interface builder, can set initial distance between 2 objects please. in action (or delegate method) change constant
of constraint.
distanceconstraint.constant = 0 uiview.animatewithduration(0.3) { self.view.layoutifneeded() }
similarly, set constant original distance when want show button again.
Comments
Post a Comment