This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func updateAccessibility() { | |
isAccessibilityElement = true | |
if let text = text { | |
accessibilityLabel = text | |
} else if let attributedText = attributedText { | |
accessibilityLabel = attributedText.string | |
} | |
accessibilityTraits = .staticText | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func generateTextMask() -> CGImage? { | |
guard frame.size.width != 0.0, | |
frame.size.height != 0.0, | |
let attributedString = maskAttributedText() else { | |
return nil | |
} | |
let bitmap = Bitmap(width: frame.size.width, height: frame.size.height) | |
bitmap.context.clear(bitmap.bounds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setupBackgroundVideoIfNeeded() { | |
guard playerLayer == nil, let url = url else { | |
return | |
} | |
let player = AVPlayer(url: url) | |
if let playerItem = player.currentItem { | |
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: playerItem, queue: nil) { [weak self] notification in | |
let currentItem = notification.object as? AVPlayerItem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func layoutSubviews() { | |
super.layoutSubviews() | |
setupBackgroundVideoIfNeeded() | |
updateVideoMask() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This initilizer will use the UIFont.preferredFont(forTextStyle: .largeTitle) | |
init(text: String, url: URL) { | |
self.text = text | |
self.url = url | |
super.init(frame: .zero) | |
} | |
// This initilizer will the use the font attribute of the text, | |
// otherwise it will revert to UIFont.preferredFont(forTextStyle: .largeTitle) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func popAnimation() { | |
let delay = DispatchTime.now() + 0.8 | |
DispatchQueue.main.asyncAfter(deadline: delay) { | |
self.numberOfAnimations -= 1 | |
if self.numberOfAnimations == 0 { | |
withAnimation(Animation.easeInOut(duration: 0.15)) { | |
self.durationLabelOpacity = 1.0 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func incrementSeekValue() -> String { | |
var valueString = accumulationString | |
valueString.removeFirst() | |
if var value = Int(valueString) { | |
value += interval | |
return "+" + String(value) | |
} | |
return accumulationString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func animateAccumulationLabel() { | |
// Reset the labels animation values | |
accumulationLabelOpacity = 0 | |
xOffset = 0.0 | |
// Fade in | |
withAnimation(.easeInOut(duration: 0.1)) { | |
accumulationLabelOpacity = 1.0 | |
} | |
NewerOlder