4

I'm trying to add a scale-up animation to the marker using UIView.animate() but it doesn't seem to work. Here's what I did...

class BubbleMarkerView: MarkerView {
    
    @IBOutlet weak var gradeLabel: UILabel!
    @IBOutlet weak var bubbleView: UIView!
    
    override open func awakeFromNib() {
        self.offset.x = -self.frame.size.width / 2.0
        self.offset.y = -self.frame.size.height + 1.0
    }
    
    override func layoutIfNeeded() {
        super.layoutIfNeeded()
        
        bubbleView.transform = CGAffineTransform(scaleX: 0, y: 0)
        
        UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: [], animations: { [weak self] in
            self?.bubbleView.transform = .identity
        }, completion: nil)
    }
    
    override func refreshContent(entry: ChartDataEntry, highlight: Highlight) {
        gradeLabel.text = "\(Int(entry.y))"
        layoutIfNeeded()
    }

}

also I'm loading this marker from a xib like this:

let marker = BubbleMarkerView.viewFromXib() as! BubbleMarkerView
marker.chartView = self
self.marker = marker

Also tried adding CABasicAnimation to bubbleView but no luck

Anyone else faced this issue? Please advice...

Nobin Jacob
  • 573
  • 5
  • 9

0 Answers0