Youtube Tutorial: Lets Build That App
Story Source: Æsop for Children
Pictures Source: Storytime,
Meridian Financial Partners, Inc.
The race is not always to the swift.(but to Swift 4!?)
@objc func handleUpdate() {
let now = Date()
let elapsedTime = now.timeIntervalSince(animationStartDate)
let percentage = elapsedTime/speed
let nowShowing = Int(percentage * (endValue - startValue))
let index = storyString!.index(storyString!.startIndex, offsetBy: nowShowing)
let mySubstring = String(storyString![..<index])
self.attributedText = applyFancy(normal: mySubstring)
if nowShowing >= storyString!.count {
displayLink.invalidate()
delegate?.endAnimation(nextTag: paragraphCounter)
}
}
Every time the frame updates trigger this method. This method calculates what is the length should be shown at that moment. Therefore, the paragraph works like animation.
- CADisplayLink
- MVC Structure
- Delegation Pattern
- Basic Animation
- Theme Configuration
- Clean Code(Refactoring)