Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. class DrawView: NSView {
  2.  
  3. ..................
  4.  
  5. let delegate = NSApplication.sharedApplication().delegate as! AppDelegate
  6.  
  7. delegate.appArray = myArray.flatMap { $0.coord() }
  8. }
  9.  
  10. class AppDelegate: NSObject, NSApplicationDelegate {
  11.  
  12. @IBOutlet weak var window: NSWindow!
  13. @IBOutlet weak var drawingView: DrawView!
  14. @IBOutlet weak var label: NSTextField!
  15.  
  16. var appArray: [CGPoint] = []
  17.  
  18. func applicationDidFinishLaunching(aNotification: NSNotification) {
  19.  
  20. label.textColor = NSColor(calibratedRed: 0.85, green: 0, blue: 0.05, alpha: 0.7)
  21. label.font! = NSFont(name: "Arial Bold", size: 60)!
  22. label.backgroundColor = NSColor.clearColor()
  23.  
  24. dispatch_async(dispatch_get_main_queue(), {
  25. self.label.stringValue = "(self.appArray.count/4)"
  26. })
  27.  
  28. for pointIndex in 0..<appArray.count {
  29.  
  30. let point = CGPoint(x:(appArray[pointIndex].x), y:(appArray[pointIndex].y))
  31.  
  32. label.sizeToFit()
  33.  
  34. label.frame = CGRect(origin: point, size:
  35. CGSize(width: label.bounds.width, height: label.bounds.height))
  36. }
  37. }
  38. }
  39.  
  40. class AppDelegate: NSObject, NSApplicationDelegate {
  41.  
  42. @IBOutlet weak var window: NSWindow!
  43. @IBOutlet weak var drawingView: DrawView!
  44. @IBOutlet weak var label: NSTextField!
  45.  
  46. var appArray: [CGPoint] = []
  47.  
  48. func applicationWillUpdate(aNotification: NSNotification) {
  49.  
  50. label.textColor = NSColor(calibratedRed: 0.15, green: 0, blue: 0.75, alpha: 0.3)
  51. label.font! = NSFont(name: "Arial Bold", size: 60)!
  52. label.backgroundColor = NSColor.clearColor()
  53.  
  54. dispatch_async(dispatch_get_main_queue(), {
  55. if self.appArray.count != 0 {
  56. self.label.stringValue = "(self.appArray.count/4)"
  57. } else {
  58. self.label.stringValue = ""
  59. }
  60. })
  61.  
  62. for pointIndex in 0..<(appArray.count/4) {
  63.  
  64. let point = CGPoint(x:(appArray[pointIndex * 4].x), y:(appArray[pointIndex * 4].y))
  65.  
  66. label.sizeToFit()
  67.  
  68. label.frame = CGRect(origin: point, size: CGSize(width: label.bounds.width, height: label.bounds.height))
  69. }
  70.  
  71. label.wantsUpdateLayer
  72.  
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement