Skip to content

Commit

Permalink
Add fade effect when intro change
Browse files Browse the repository at this point in the history
  • Loading branch information
iWECon committed Dec 1, 2022
1 parent 6e6d8ae commit 1dea74b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Sources/Marker/Marker+Draw.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,23 @@ extension Marker {
}

internal func setupIntro(calculate: Calculate) {
if let introString = current.intro as? String {
contentLabel.text = introString
} else if let attributedString = current.intro as? NSAttributedString {
contentLabel.attributedText = attributedString
// make content change has a fade effect
contentLabel.layer.removeAnimation(forKey: "marker-fade-animation")
let transition = CATransition()
transition.timingFunction = CAMediaTimingFunction(name: .easeOut)
transition.type = .fade
transition.duration = animateDuration
contentLabel.layer.add(transition, forKey: "marker-fade-animation")

// change content
if let introString = calculate.info.intro as? String {
self.contentLabel.text = introString
} else if let attributedString = calculate.info.intro as? NSAttributedString {
self.contentLabel.attributedText = attributedString
} else {
contentLabel.text = "Can not support this type: \(type(of: current.intro))"
self.contentLabel.text = "Can not support this type: \(type(of: calculate.info.intro))"
}
contentLabel.frame.size = calculate.calculateContentSize(label: contentLabel)
self.contentLabel.frame.size = calculate.calculateContentSize(label: self.contentLabel)
}

internal func setupDimmingView(calculate: Calculate) {
Expand Down

0 comments on commit 1dea74b

Please sign in to comment.