iOS/Swift 문법

[Swift] For루프와 Timer를 이용한 titleText 한 글자씩 나타나게 하기

Chafle 2022. 8. 30. 16:27
반응형
 override func viewDidLoad() {
        super.viewDidLoad()

        titleLabel.text = ""
        var charIndex = 0.0
        let titleText = "께께오톡"
        for letter in titleText {
            Timer.scheduledTimer(withTimeInterval: 0.1 * charIndex, repeats: false) { timer in
                self.titleLabel.text?.append(letter)
            }
            charIndex += 1
반응형