func attributedUrlStringWith(link: URL, font: UIFont?, color: UIColor, lineHeight: CGFloat = 0, alignment: NSTextAlignment = .left) -> NSAttributedString? { guard let font = font else { assertionFailure("Error creating attributed string. Reason: provided font is nil. \nString: \(self)") return nil } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = alignment if lineHeight != 0 { paragraphStyle.minimumLineHeight = lineHeight } let attributes: [NSAttributedStringKey: Any] = [.paragraphStyle: paragraphStyle, .font: font, .foregroundColor: color, .link: link] let attributedString = NSAttributedString(string: self, attributes: attributes) return attributedString }