From 0c164a170cfb81c94374871c2edcb626a2e21a54 Mon Sep 17 00:00:00 2001 From: sunxiaojian Date: Fri, 12 Mar 2021 15:53:19 +0800 Subject: [PATCH] chore: use rounded font --- .../Share/View/Container/PlayerContainerView.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Mastodon/Scene/Share/View/Container/PlayerContainerView.swift b/Mastodon/Scene/Share/View/Container/PlayerContainerView.swift index d002e13a..3b4acc98 100644 --- a/Mastodon/Scene/Share/View/Container/PlayerContainerView.swift +++ b/Mastodon/Scene/Share/View/Container/PlayerContainerView.swift @@ -28,7 +28,6 @@ final class PlayerContainerView: UIView { let mediaTypeIndicotorLabel: UILabel = { let label = UILabel() - label.font = .systemFont(ofSize: 18, weight: .heavy) label.textColor = .white label.textAlignment = .right label.translatesAutoresizingMaskIntoConstraints = false @@ -162,12 +161,21 @@ extension PlayerContainerView { 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) { + let fontSize: CGFloat = 18 + switch kind { case .gif: + mediaTypeIndicotorLabel.font = roundedFont(weight: .heavy, fontSize: fontSize) mediaTypeIndicotorLabel.text = "GIF" 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 attachment = NSTextAttachment() attachment.image = image.withTintColor(.white)