MiniPlayer/Sources/AirPlayButton.swift

26 lines
709 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
import AVKit
#if os(iOS)
/// AirPlay 投屏按钮 — 封装 AVRoutePickerView
/// 点击后弹出系统 AirPlay 设备选择面板
struct AirPlayButton: UIViewRepresentable {
/// 按钮颜色(默认白色)
var tintColor: UIColor = .white
func makeUIView(context: Context) -> AVRoutePickerView {
let picker = AVRoutePickerView()
picker.tintColor = tintColor
picker.activeTintColor = UIColor.systemBlue
// 使按钮在深色背景下可见
picker.backgroundColor = .clear
return picker
}
func updateUIView(_ uiView: AVRoutePickerView, context: Context) {
uiView.tintColor = tintColor
}
}
#endif