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