๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ384

UIImageView ์ด๋ฏธ์ง€ ๋ทฐ(Image View) ์•ฑ์—์„œ ์‚ฌ์ง„์„ ๋ณด์—ฌ ์ค˜์•ผ ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ฒด 1. ์ด๋ฏธ์ง€ ๋ทฐ ์ถ”๊ฐ€ Library์—์„œ Image View๋ฅผ ์ฐพ์•„ ํ™”๋ฉด์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ํ™”๋ฉด์— ์ด๋ฏธ์ง€ ๋ทฐ ๊ฐ์ฒด๊ฐ€ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. 2. ์ด๋ฏธ์ง€ ๋ทฐ์— ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ ์ด๋ฏธ์ง€ ๋ทฐ์— ์ด๋ฏธ์ง€๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ํฌ๊ฒŒ ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ๋กœ๋Š” ํ”„๋กœ์ ํŠธ์— ์ด๋ฏธ์ง€๋ฅผ ์ถ”๊ฐ€ํ•œ ํ›„ 'Attribute Inspector'์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์„ ํƒํ•ด ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. imageView.image = UIImage(named: "lamp-on.png") ๋‘ ๋ฒˆ์งธ๋กœ๋Š” ์†Œ์Šค์ฝ”๋“œ์— ์ด๋ฏธ์ง€ ๋ทฐ ๊ฐ์ฒด๋ฅผ ์•„์›ƒ๋ › ๋ณ€์ˆ˜๋กœ ์ถ”๊ฐ€ํ•œ ํ›„ UIImage ํƒ€์ž…์˜ ์ด๋ฏธ์ง€๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. 3. ์ด๋ฏธ์ง€ ๋ทฐ ์ฝ˜ํ…์ธ  ๋ชจ๋“œ ์ด๋ฏธ์ง€ ๋ทฐ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ฝ˜ํ…์ธ  ๋ชจ๋“œ(Content .. 2022. 9. 28.
Outlet ๋ณ€์ˆ˜์™€ Action ํ•จ์ˆ˜ ์•„์›ƒ๋ › ๋ณ€์ˆ˜(Outlet Variable) ์Šคํ† ๋ฆฌ๋ณด๋“œ์—์„œ ์ถ”๊ฐ€ํ•œ ๊ฐ์ฒด์˜ ๋‚ด์šฉ์„ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ํŠน์ •ํ•œ ๋™์ž‘์„ ํ•˜๊ธฐ ์œ„ํ•ด ๊ฐ์ฒด์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ 1. ์•„์›ƒ๋ › ๋ณ€์ˆ˜ ์ถ”๊ฐ€ 'Test'๋ผ๋Š” Label ๊ฐ์ฒด์•  ๋Œ€ํ•ด์„œ ์•„์›ƒ๋ › ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. Label ๊ฐ์ฒด๋ฅผ ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ๋ฒ„ํŠผ์œผ๋กœ ์„ ํƒํ•˜๊ณ , ๋ณด์กฐ ํŽธ์ง‘๊ธฐ ์˜์—ญ์œผ๋กœ ๋“œ๋ž˜๊ทธํ•˜์—ฌ ํด๋ž˜์Šค ์„ ์–ธ๋ฌธ ๋ฐ”๋กœ ์•„๋ž˜์— ํ•ด๋‹น ๊ฐ์ฒด๋ฅผ ๋Œ์–ด๋‹ค ๋†“์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์—ฐ๊ฒฐ์„ ์ด ๋‚˜ํƒ€๋‚˜๊ณ , 'Insert Outlet or Outlet Collection'์ด๋ผ๋Š” ํ‘œ์‹œ๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค. 2. ์•„์›ƒ๋ › ๋ณ€์ˆ˜ ์—ฐ๊ฒฐ ์„ค์ • ์•„์›ƒ๋ › ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์—ฐ๊ฒฐ ์„ค์ •์ฐฝ์ด ๋‚˜์˜ต๋‹ˆ๋‹ค. ๋ณ€์ˆ˜๋ช…๊ณผ type, storage๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 3. ์•„์›ƒ๋ › ๋ณ€์ˆ˜ ์†Œ์Šค์ฝ”๋“œ @IBOutlet weak var te.. 2022. 9. 27.
[Swift] Codility Lesson 5 - CountDiv ๋ฌธ์ œ Write a function: public func solution(_ A : Int, _ B : Int, _ K : Int) -> Int that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.: { i : A ≤ i ≤ B, i mod K = 0 } For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 an.. 2022. 7. 26.
[Swift] Codility Lesson 5 - PassingCars ๋ฌธ์ œ A non-empty array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: 0 represents a car traveling east, 1 represents a car traveling west. The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P is traveling to the east and Q is traveling to the .. 2022. 7. 26.
[Swift] Codility Lesson 4 - MissingInteger ๋ฌธ์ œ This is a demo task. Write a function: public func solution(_ A : inout [Int]) -> Int that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3], the function should return 1. Write an efficie.. 2022. 7. 24.
[Swift] Codility Lesson 4 - MaxCounters ๋ฌธ์ œ You are given N counters, initially set to 0, and you have two possible operations on them: increase(X) − counter X is increased by 1, max counter− all counters are set to the maximum value of any counter. A non-empty array A of M integers is given. This array represents consecutive operations: if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X), if A[K] = N + 1 then operation K.. 2022. 7. 23.
๋ฐ˜์‘ํ˜•