chore: use rounded font

This commit is contained in:
sunxiaojian 2021-03-12 15:53:19 +08:00
parent 6b5edff677
commit 0c164a170c
1 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,6 @@ final class PlayerContainerView: UIView {
let mediaTypeIndicotorLabel: UILabel = { let mediaTypeIndicotorLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.font = .systemFont(ofSize: 18, weight: .heavy)
label.textColor = .white label.textColor = .white
label.textAlignment = .right label.textAlignment = .right
label.translatesAutoresizingMaskIntoConstraints = false label.translatesAutoresizingMaskIntoConstraints = false
@ -162,12 +161,21 @@ extension PlayerContainerView {
return playerViewController return playerViewController
} }
func roundedFont(weight: UIFont.Weight,fontSize: CGFloat) -> UIFont {
let systemFont = UIFont.systemFont(ofSize: fontSize, weight: weight)
guard let descriptor = systemFont.fontDescriptor.withDesign(.rounded) else { return systemFont }
let roundedFont = UIFont(descriptor: descriptor, size: fontSize)
return roundedFont
}
func setMediaKind(kind: VideoPlayerViewModel.Kind) { func setMediaKind(kind: VideoPlayerViewModel.Kind) {
let fontSize: CGFloat = 18
switch kind { switch kind {
case .gif: case .gif:
mediaTypeIndicotorLabel.font = roundedFont(weight: .heavy, fontSize: fontSize)
mediaTypeIndicotorLabel.text = "GIF" mediaTypeIndicotorLabel.text = "GIF"
case .video: case .video:
let configuration = UIImage.SymbolConfiguration(font: .systemFont(ofSize: 18, weight: .regular)) let configuration = UIImage.SymbolConfiguration(font: roundedFont(weight: .regular, fontSize: fontSize))
let image = UIImage(systemName: "video.fill", withConfiguration: configuration)! let image = UIImage(systemName: "video.fill", withConfiguration: configuration)!
let attachment = NSTextAttachment() let attachment = NSTextAttachment()
attachment.image = image.withTintColor(.white) attachment.image = image.withTintColor(.white)