Mam dziwny problem z Xcode 6.1 GM.Swift - Tekst rysunkowy z drawInRect: withAttributes:
let text: NSString = "A"
let font = NSFont(name: "Helvetica Bold", size: 14.0)
let textRect: NSRect = NSMakeRect(5, 3, 125, 18)
let textStyle = NSMutableParagraphStyle.defaultParagraphStyle().mutableCopy() as NSMutableParagraphStyle
textStyle.alignment = NSTextAlignment.LeftTextAlignment
let textColor = NSColor(calibratedRed: 0.147, green: 0.222, blue: 0.162, alpha: 1.0)
let textFontAttributes = [
NSFontAttributeName: font,
NSForegroundColorAttributeName: textColor,
NSParagraphStyleAttributeName: textStyle
]
text.drawInRect(NSOffsetRect(textRect, 0, 1), withAttributes: textFontAttributes)
Błąd jest zgodne niech texFontAttributes ...
Cannot convert the expression's type 'Dictionary' to type 'DictionaryLiteralConvertible'
Kod ten jest doskonale pracował aż Xcode 6.1 GM.
Kiedy jestem próbował oświadczyć textFontAttributes jak komunikat o błędzie NSDictionary zostaje zmieniony na:
Cannot convert the expression's type 'NSDictionary' to type 'NSString!'
nie mam pojęcia, jak rozwiązać ten problem :(
Nie wiem dlaczego, ale 'drawAtPoint: withAttributes:' 'drawInRect: withAttributes:' 'drawWithRect: opcje: atrybuty:' ' sizeWithAttributes: 'i' boundingRectWithSize: options: attributes: 'are" Niedostępne w Swift " – JDS
@JDS Jest niedostępne nie w Swift, ale w Swift's * String * type. Możesz wywołać te metody na * NSString *, podobnie jak OP. – Blaszard