ios - UIView animation causing label to twitch -
i have iconview
class use custom image google maps marker. of print statements show code correctly executing. however, "12:08" uilabel
in circleview
keeps on growing , shrinking (i.e. twitching). can't figure out problem might be. i've tried manually setting the font in completion block, commenting out adjustsfontsizetofitwidth
, changing circleview
uibutton
.
import uikit class iconview: uiview { var timelabel: uilabel! var circleview: uiview! var clicked: bool! //constants let circleviewwidth = 50.0 let circleviewheight = 50.0 override init(frame:cgrect) { super.init(frame : frame) self.backgroundcolor = uicolor(red: 47/255, green: 49/255, blue: 53/255, alpha: 0.0) clicked = false if !clicked { //main circle print("init circle view") circleview = uiview(frame: cgrect(x:0, y:0, width:circleviewwidth, height:circleviewheight)) circleview.backgroundcolor = uicolor(red: 47/255, green: 49/255, blue: 53/255, alpha: 1.0) circleview.layer.cornerradius = circleview.frame.size.height / 2.0 circleview.layer.maskstobounds = true self.addsubview(circleview) timelabel = uilabel(frame: cgrect(x: 0, y: 0, width: circleviewwidth, height: circleviewheight/3.0)) timelabel.center = circleview.center timelabel.text = "12:08" timelabel.textalignment = .center timelabel.textcolor = .white timelabel.numberoflines = 0 timelabel.font = uifont.systemfont(ofsize: 11) timelabel.font = uifont.boldsystemfont(ofsize: 11) timelabel.adjustsfontsizetofitwidth = true circleview.addsubview(timelabel) } } required init?(coder adecoder: nscoder) { super.init(coder: adecoder) } }
func mapview(_ mapview: gmsmapview, didtap marker: gmsmarker) -> bool { let iconview = marker.iconview as! iconview print("going start animating") if !iconview.clicked { uiview.animate(withduration: 0.2, animations: { print("making bigger now") iconview.circleview.transform = cgaffinetransform(scalex: 1.2, y: 1.2) }) { (finished:bool) -> void in print("done") iconview.clicked = true } } return true }
Comments
Post a Comment