2021 Monthly I Learned - kirseia/study GitHub Wiki

2021. 12
  • SwiftUI ์—์„œ ๋ณด์ด๋Š” ์˜์—ญ clipping ์€ .clipped() ์ด๊ณ , ํ„ฐ์น˜ ์˜์—ญ clipping ์€ contentShape ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
    • ์ด๋ฏธ์ง€๊ฐ€ ๊ฐ€๋กœ๋กœ๊ธธ์–ด์„œ .clipped() ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ค„์˜€์œผ๋‚˜ ํ„ฐ์น˜ ์˜์—ญ์ด ๋‹ค๋ฅธ ๋ฒ„ํŠผ์„ ์นจ๋ฒ”ํ•ด์„œ ํ„ฐ์น˜๊ฐ€ ์•ˆ๋˜๋Š” ์ด์Šˆ๊ฐ€ ์žˆ์—ˆ์Œ (.clipped() ํ•˜๊ณ  .contentShape() ๋ฅผ ๊ฐ™์ด ์‚ฌ์šฉํ•ด์„œ ํ•ด๊ฒฐ)
  • SF Symbols - symbolVariant(_:) methods (from iOS15)
2021. 11
2021. 10
2021. 9
2021. 8
2021. 7
2021. 6
2021. 5
2021. 4
2021. 3
2021. 2
var isSlowMotionVideo: Bool {
    guard let segments = avasset.tracks(withMediaType: .video).last?.segments else {
        return false
    }

    if segments.count <= 1 {
        return false
    }

    return segments.contains { (segment) -> Bool in
        let timeMapping = segment.timeMapping
        // 0.5๋ฐฐ์† ์ดํ•˜์˜ ๊ฐ’์„ ๊ฐ€์ง„๊ฒŒ ์žˆ๋‹ค๋ฉด
        return (timeMapping.target.duration.seconds / timeMapping.source.duration.seconds) > 2.0
    }
}
let sourceTimeRange = CMTimeRange(start: .zero, duration: CMTime(value: 30, timeScale: 30))
let ratedCompositionDuraiton = CMTime(Value: 17, timeScale: 30)

try videoCompositionTrack.insertTimeRange(sourceTimeRange, of: videoAssetTrack, at: startTime)
videoCompositionTrack.scaleTimeRange(CMTimeRange(start: startTime, duration: sourceTimeRange.duration),
                                                         toDuration: ratedCompositionDuration)

์ด๋ผ๊ณ  ํ–ˆ์„ ๋•Œ videoCompositionTrack.timeRange.duration != ratedCompositionDuration ์ด ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ๊ฐ€ ๊ฐ„ํ˜น ์žˆ์Œ.
์˜ˆ๋ฅผ ๋“ค์–ด, videoCompositionTrack.timeRange.duration์ด CMTime(value: 5666666667, timeScale: 1000000000)
์ด๋ ‡๊ฒŒ ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋Š”๋ฐ, ํฌ๊ฒŒ ๋ฌธ์ œ๊ฐ€ ์•ˆ๋˜๋Š”๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด๋‚˜, ์ด ๋‹ค์Œ ํŠธ๋ž™์„ insert ํ•  ๋•Œ startTime ์— ์œ„ ๊ฐ’์„ ๋ฐ˜์˜ํ•ด์ค˜์•ผ ํ•จ
๋˜๋Š”, ์Œ์•… ํŠธ๋ž™์ด ๋น„๋””์˜ค ๊ธฐ์ค€์œผ๋กœ ๋„ฃ์–ด์ค˜์•ผ ํ•˜๋Š”๋ฐ ์ด ๊ฐ’์„ ๋„˜๋Š” ๊ฒฝ์šฐ ์ถ”๊ฐ€์ ์ธ ๋ณด์ •์ด ํ•„์š”ํ•˜๋‹ค
2021. 1