I am trying to create AttributedString and add the attributes from
typingAttributes(from textView)
The problem is that
.typingAt
Here is my helper class, which I use custom fonts
import UIKit
struct AttributedStringHelper {
enum FontType: String {
case bold = "GothamRounded-Bold"
case medium = "GothamRounded-Medium"
case book = "GothamRounded-Book"
}
static func getString(text: String, fontType: FontType, size: CGFloat, color: UIColor, isUnderlined: Bool? = nil) -> NSAttributedString {
var attributes : [NSAttributedStringKey : Any] = [
NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue) : UIFont(name: fontType.rawValue, size: size)!,
NSAttributedStringKey.foregroundColor : color]
if let isUnderlined = isUnderlined, isUnderlined {
attributes[NSAttributedStringKey.underlineStyle] = 1
}
let attributedString = NSAttributedString(string: text, attributes: attributes)
return attributedString
}
}