ios - Update UILabel frame and text continously -
i trying move uilabel follow finger using touchmoved. , updating current frame label text.
label shuttered not moving accordingly. if comment 1 moving or updating text working
i made sample have uilabel
, add pan gesture recognizer, change frame according location in view of superview example it's here : self.view
. remember add userinteractionenabled = true
uilabel
. luck
@iboutlet var label: uilabel! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let pangesturerecognizer = uipangesturerecognizer(target: self, action: #selector(self.handlepan(_:))) label.addgesturerecognizer(pangesturerecognizer) label.userinteractionenabled = true } func handlepan(gesturerecognizer: uipangesturerecognizer) { let location = gesturerecognizer.locationinview(self.view) var frame = label.frame frame.origin.x = location.x frame.origin.y = location.y label.frame = frame }
Comments
Post a Comment