मुझे एक्सकोड 6.1 जीएम के साथ अजीब समस्या है।स्विफ्ट - DrawInRect के साथ टेक्स्ट ड्रॉइंग: एट्रिब्यूट्स:
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)
त्रुटि लाइन में texFontAttributes जाने है ...
Cannot convert the expression's type 'Dictionary' to type 'DictionaryLiteralConvertible'
इस कोड को पूरी तरह से जब तक Xcode 6.1 जीएम काम किया है।
जब मैं NSDictionary त्रुटि संदेश के रूप में textFontAttributes घोषित करने की कोशिश कर रहा हूँ करने के लिए बदल जाता है:
Cannot convert the expression's type 'NSDictionary' to type 'NSString!'
मैं पता नहीं कैसे इस समस्या को :(
मैं नहीं जानता कि क्यों, लेकिन 'drawAtPoint: withAttributes:' 'drawInRect: withAttributes:' 'drawWithRect: विकल्प: विशेषताएं:' ' sizeWithAttributes: 'और' boundingRectWithSize: विकल्प: विशेषताएं: '" स्विफ्ट में उपलब्ध नहीं हैं " – JDS
@JDS यह स्विफ्ट में नहीं है लेकिन स्विफ्ट के * स्ट्रिंग * प्रकार। ओपी के रूप में आप उन तरीकों को * एनएसएसटींग * पर कॉल कर सकते हैं। – Blaszard