애플 기본 날씨 앱에서 컬렉션뷰의 헤더의 Label에 SFSymbol이 같이 구현되어 있다.

UILabel의 TextAttribute 프로퍼티를 활용하여 구현할 수 있다.

NSTextAttachment의 image 프로퍼티에 UIImage를 할당하여 구현.

UIImage의 SymbolConfiguration로 사이즈, 웨이트, 스케일을 설정해 줄 수 있다.

extension String {
    func attach(
        with imageName: String,
        pointSize: CGFloat,
        tintColor: UIColor
    ) -> NSAttributedString {
        let imageAttachment = NSTextAttachment()
        let imageConfig = UIImage.SymbolConfiguration(
            pointSize: pointSize,
            weight: .regular,
            scale: .default
        )
        imageAttachment.
        imageAttachment.image = UIImage(
            systemName: imageName,
            withConfiguration: imageConfig
        )?.withTintColor(tintColor)
        let fullString = NSMutableAttributedString(string: "")
        fullString.append(NSAttributedString(attachment: imageAttachment))
        fullString.append(NSAttributedString(string: " \(self)"))

        return fullString
    }
}

결과물