Having trouble creating the HudView. I’m in HudView swift and am using the dictionary to set the font size and color of the Hud text. I’m getting an error " Use of unresolved identifiers ‘NSFontAttributeName’ and ‘NSForegroundColorAttributeName’ ".
I’ve seen this error before when I’ve forgotten to import UIKit or something like that, but I can’t see anywhere in the instructions about importing an NSObject or NS something else. What’s going on here? Should I import something or has Swift changed the identifiers it uses?
Heres my code:
Blockquote
override func draw(_ rect: CGRect) {
let boxWidth: CGFloat = 96
let boxHeight: CGFloat = 96
let boxRect = CGRect(x: round((bounds.size.width - boxWidth) / 2), y: round((bounds.size.height - boxHeight) / 2 ), width: boxWidth, height: boxHeight)
let roundedRect = UIBezierPath(roundedRect: boxRect, cornerRadius: 10)
UIColor(white: 0.3, alpha: 0.8).setFill()
roundedRect.fill()
if let image = UIImage(named: "Checkmark") {
let imagePoint = CGPoint( x: center.x - round(image.size.width / 2), y: center.y - round(image.size.height / 2) - boxHeight / 8)
image.draw(at: imagePoint)
}
// Create a UIFont object, choose a color for the text, and place it into a dictionary
let attribs = [ NSFontAttributeName: UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName: UIColor.white ]
let textSize = text.size(attributes: attribs)
let textPoint = CGPoint( x: center.x - round(textSize.width / 2), y: center.y - round(textSize.height / 2) + boxHeight / 4)
text.draw(at: textPoint, withAttributes: attribs)
}
}