【发布时间】:2017-08-15 14:42:50
【问题描述】:
如何将'[String : AnyObject]?'类型的值转换为预期的参数类型'[NSAttributedStringKey : Any]?'?
open class func drawText(context: CGContext, text: String, point: CGPoint,
align: NSTextAlignment, attributes: [String : AnyObject]?)
{
var point = point
if align == .center
{
point.x -= text.size(withAttributes: attributes).width / 2.0
}
else if align == .right
{
point.x -= text.size(withAttributes: attributes).width
}
NSUIGraphicsPushContext(context)
(text as NSString).draw(at: point, withAttributes: attributes)
NSUIGraphicsPopContext()
}
【问题讨论】:
标签: swift nsattributedstring swift4 nsattributedstringkey