728x90
์ฐ์ปด ํ๋ฉด์ ๊ธ์๋ฅผ ํ์ดํ ์น๋ ๋ฏํ ์ ๋๋ฉ์ด์ ์ผ๋ก ํํํด๋ณด์.
1. TextLabel ์คํฌ๋ฆฝํธ์ ์ฐ๊ฒฐ
2. ๋ฐ๋ณต๋ฌธ์ ํ์ด๋จธ ์ถ๊ฐ
import UIKit
class WelcomeViewController: UIViewController {
@IBOutlet weak var titleLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
titleLabel.text = ""
var charIndex = 0.0
let titleText = "โก๏ธFlashChat"
for letter in titleText{
print("-")
print(0.1 * charIndex)
print(letter)
Timer.scheduledTimer(withTimeInterval: 0.1 * charIndex, repeats: false){ (timer) in
self.titleLabel.text?.append(letter)
}
charIndex += 1
}
}
}
ํ์ด๋จธ ๊ฐ๊ฒฉ์ 0.1๋ง ๋ฃ์ด์ฃผ๋ฉด ๋ชจ๋ ๊ธ์๊ฐ 0.1์ด๋ง์ ์ถ๋ ฅ๋๋ฏ๋ก 0.1์ charIndex ๊ณฑํด์ค์ 0.1, 0.2, ... ์ด๋ฐ์์ผ๋ก ๊ฐ์ ๋ถ์ฌํด์ฃผ์ด์ผ ํ๋ค. ๊ธฐํ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์์ง๋ง ๊ฐ๋จํ๊ฒ ์์ฒ๋ผ ๊ตฌํ์ด ๊ฐ๋ฅํ๋ค.
[์ฃผ์ ์ถ๋ ฅ ๊ฒฐ๊ณผ]
-
0.0
โก๏ธ
-
0.1
F
-
0.2
l
-
0.30000000000000004
a
-
0.4
s
-
0.5
h
-
0.6000000000000001
C
-
0.7000000000000001
h
-
0.8
a
-
0.9
t
3. ๊ฒฐ๊ณผ๋ฌผ ํ์ธ
728x90
'๐ฑ App Development Study > iOS๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Udemy iOS & Swift Bootcamp] 1. Firebase ์ถ๊ฐํ๊ธฐ (0) | 2023.06.19 |
---|---|
[Udemy iOS & Swift Bootcamp] 3rd Party Libraries & Cocoapods (1) | 2023.06.18 |
[Udemy iOS & Swift Bootcamp] Navigation Controller Stack (0) | 2023.06.17 |
Apple Property Lists Document (0) | 2023.05.17 |
[Udemy iOS & Swift Bootcamp] ํ์ฌ ์์น ์ ๋ณด ์ฌ์ฉํ๊ธฐ (0) | 2023.05.15 |