iDhaval/DTTextField

NSAttributedStringKey doesn't work

Closed this issue · 3 comments

public var placeholderColor:UIColor?{
didSet{
guard let color = placeholderColor else { return }
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
attributes: [NSAttributedStringKey.foregroundColor:color])
}
}

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

how to fix it?

which swift version are you using?

If you're using the library from a pod, in your workspace select the DTTextField target in the Pod project. Browse down to "Swift Language Version" and switch it to > Swift 4.0.
When I added the pod the compiler was set on version 3.3 which was causing that code block to result in an error.

Upgraded to swift 5.0