Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DrawView: NSView {
- ..................
- let delegate = NSApplication.sharedApplication().delegate as! AppDelegate
- delegate.appArray = myArray.flatMap { $0.coord() }
- }
- class AppDelegate: NSObject, NSApplicationDelegate {
- @IBOutlet weak var window: NSWindow!
- @IBOutlet weak var drawingView: DrawView!
- @IBOutlet weak var label: NSTextField!
- var appArray: [CGPoint] = []
- func applicationDidFinishLaunching(aNotification: NSNotification) {
- label.textColor = NSColor(calibratedRed: 0.85, green: 0, blue: 0.05, alpha: 0.7)
- label.font! = NSFont(name: "Arial Bold", size: 60)!
- label.backgroundColor = NSColor.clearColor()
- dispatch_async(dispatch_get_main_queue(), {
- self.label.stringValue = "(self.appArray.count/4)"
- })
- for pointIndex in 0..<appArray.count {
- let point = CGPoint(x:(appArray[pointIndex].x), y:(appArray[pointIndex].y))
- label.sizeToFit()
- label.frame = CGRect(origin: point, size:
- CGSize(width: label.bounds.width, height: label.bounds.height))
- }
- }
- }
- class AppDelegate: NSObject, NSApplicationDelegate {
- @IBOutlet weak var window: NSWindow!
- @IBOutlet weak var drawingView: DrawView!
- @IBOutlet weak var label: NSTextField!
- var appArray: [CGPoint] = []
- func applicationWillUpdate(aNotification: NSNotification) {
- label.textColor = NSColor(calibratedRed: 0.15, green: 0, blue: 0.75, alpha: 0.3)
- label.font! = NSFont(name: "Arial Bold", size: 60)!
- label.backgroundColor = NSColor.clearColor()
- dispatch_async(dispatch_get_main_queue(), {
- if self.appArray.count != 0 {
- self.label.stringValue = "(self.appArray.count/4)"
- } else {
- self.label.stringValue = ""
- }
- })
- for pointIndex in 0..<(appArray.count/4) {
- let point = CGPoint(x:(appArray[pointIndex * 4].x), y:(appArray[pointIndex * 4].y))
- label.sizeToFit()
- label.frame = CGRect(origin: point, size: CGSize(width: label.bounds.width, height: label.bounds.height))
- }
- label.wantsUpdateLayer
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement