├── Panel
├── Panel.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ └── xcschemes
│ │ ├── Panel.xcscheme
│ │ └── xcschememanagement.plist
└── Panel
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Info.plist
│ ├── MainWindowController.h
│ ├── MainWindowController.m
│ ├── MainWindowController.xib
│ ├── loginButton_backgroundImage.png
│ └── main.m
├── 基本控件(NSCollectionView)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── CustomCollectionViewItem.h
│ ├── CustomCollectionViewItem.m
│ ├── CustomCollectionViewItem.xib
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSDatePicker)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSMenu)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── MainWindowController.h
│ ├── MainWindowController.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSOutlineView)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── Node.h
│ ├── Node.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSPopover)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── LoginViewController.h
│ ├── LoginViewController.m
│ ├── LoginViewController.xib
│ ├── ShareViewController.h
│ ├── ShareViewController.m
│ ├── ShareViewController.xib
│ ├── ShowViewController.h
│ ├── ShowViewController.m
│ ├── ShowViewController.xib
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSSearchFiled)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSSegmentedControl)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSSplitView)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── Masonry
│ ├── Info.plist
│ ├── MASCompositeConstraint.h
│ ├── MASCompositeConstraint.m
│ ├── MASConstraint+Private.h
│ ├── MASConstraint.h
│ ├── MASConstraint.m
│ ├── MASConstraintMaker.h
│ ├── MASConstraintMaker.m
│ ├── MASLayoutConstraint.h
│ ├── MASLayoutConstraint.m
│ ├── MASUtilities.h
│ ├── MASViewAttribute.h
│ ├── MASViewAttribute.m
│ ├── MASViewConstraint.h
│ ├── MASViewConstraint.m
│ ├── Masonry.h
│ ├── NSArray+MASAdditions.h
│ ├── NSArray+MASAdditions.m
│ ├── NSArray+MASShorthandAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.m
│ ├── View+MASAdditions.h
│ ├── View+MASAdditions.m
│ ├── View+MASShorthandAdditions.h
│ ├── ViewController+MASAdditions.h
│ └── ViewController+MASAdditions.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSStatusBar)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Info.plist
│ ├── arrow.png
│ └── main.m
├── 基本控件(NSTabView)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── Masonry
│ ├── Info.plist
│ ├── MASCompositeConstraint.h
│ ├── MASCompositeConstraint.m
│ ├── MASConstraint+Private.h
│ ├── MASConstraint.h
│ ├── MASConstraint.m
│ ├── MASConstraintMaker.h
│ ├── MASConstraintMaker.m
│ ├── MASLayoutConstraint.h
│ ├── MASLayoutConstraint.m
│ ├── MASUtilities.h
│ ├── MASViewAttribute.h
│ ├── MASViewAttribute.m
│ ├── MASViewConstraint.h
│ ├── MASViewConstraint.m
│ ├── Masonry.h
│ ├── NSArray+MASAdditions.h
│ ├── NSArray+MASAdditions.m
│ ├── NSArray+MASShorthandAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.m
│ ├── View+MASAdditions.h
│ ├── View+MASAdditions.m
│ ├── View+MASShorthandAdditions.h
│ ├── ViewController+MASAdditions.h
│ └── ViewController+MASAdditions.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSTableView_ 纯代码)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── CustomTableCellView.h
│ ├── CustomTableCellView.m
│ ├── CustomTableRowView.h
│ ├── CustomTableRowView.m
│ ├── Info.plist
│ ├── Masonry
│ ├── Info.plist
│ ├── MASCompositeConstraint.h
│ ├── MASCompositeConstraint.m
│ ├── MASConstraint+Private.h
│ ├── MASConstraint.h
│ ├── MASConstraint.m
│ ├── MASConstraintMaker.h
│ ├── MASConstraintMaker.m
│ ├── MASLayoutConstraint.h
│ ├── MASLayoutConstraint.m
│ ├── MASUtilities.h
│ ├── MASViewAttribute.h
│ ├── MASViewAttribute.m
│ ├── MASViewConstraint.h
│ ├── MASViewConstraint.m
│ ├── Masonry.h
│ ├── NSArray+MASAdditions.h
│ ├── NSArray+MASAdditions.m
│ ├── NSArray+MASShorthandAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.h
│ ├── NSLayoutConstraint+MASDebugAdditions.m
│ ├── View+MASAdditions.h
│ ├── View+MASAdditions.m
│ ├── View+MASShorthandAdditions.h
│ ├── ViewController+MASAdditions.h
│ └── ViewController+MASAdditions.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSTableView_CellBased)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSTableView_ViewBased)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSTextField & NSTextView)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(NSToolbar)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── MainWindowController.h
│ ├── MainWindowController.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 基本控件(Radio)
├── 基本控件.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 基本控件.xcscheme
└── 基本控件
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── 模态窗口
├── 模态窗口.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihongfeng.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── 模态窗口.xcscheme
└── 模态窗口
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Info.plist
│ ├── ModeWindow.h
│ ├── ModeWindow.m
│ ├── ModeWindow.xib
│ └── main.m
└── 自定义面板
├── 自定义面板.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── lihongfeng.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── lihongfeng.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── xcschememanagement.plist
│ └── 自定义面板.xcscheme
└── 自定义面板
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
└── AppIcon.appiconset
│ └── Contents.json
├── Base.lproj
└── MainMenu.xib
├── CustomPanel.h
├── CustomPanel.m
├── CustomPanel.xib
├── Info.plist
├── MainViewController.h
├── MainViewController.m
├── MainViewController.xib
├── MainWindowController.h
├── MainWindowController.m
├── MainWindowController.xib
└── main.m
/Panel/Panel.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Panel/Panel.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/Panel/Panel.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Panel/Panel.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Panel.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 61E8EE551DFA9B9E00219D66
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Panel/Panel/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Panel
4 | //
5 | // Created by lihongfeng on 16/12/9.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/Panel/Panel/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // Panel
4 | //
5 | // Created by lihongfeng on 16/12/9.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainWindowController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @property (nonatomic, strong) MainWindowController *mainWindowController;
15 |
16 | @end
17 |
18 | @implementation AppDelegate
19 |
20 | - (IBAction)openFile:(id)sender {
21 | NSLog(@"------open file.");
22 | }
23 |
24 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
25 | // Insert code here to initialize your application
26 | [self.mainWindowController showWindow:self];
27 | }
28 |
29 | - (MainWindowController *)mainWindowController{
30 | if (!_mainWindowController) {
31 | _mainWindowController = [[MainWindowController alloc] init];
32 | }
33 | return _mainWindowController;
34 | }
35 |
36 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
37 | // Insert code here to tear down your application
38 | }
39 |
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/Panel/Panel/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Panel/Panel/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Panel/Panel/MainWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.h
3 | // Panel
4 | //
5 | // Created by lihongfeng on 16/12/9.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainWindowController : NSWindowController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Panel/Panel/loginButton_backgroundImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/Panel/Panel/loginButton_backgroundImage.png
--------------------------------------------------------------------------------
/Panel/Panel/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Panel
4 | //
5 | // Created by lihongfeng on 16/12/9.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSCollectionView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/CustomCollectionViewItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomCollectionViewItem.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CustomCollectionViewItem : NSCollectionViewItem
12 |
13 | - (void)itemClickHandler:(void (^)(NSString *title))clickHandler;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/CustomCollectionViewItem.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSCollectionView)/基本控件/CustomCollectionViewItem.m
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CustomCollectionViewItem.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property (nonatomic, strong) NSCollectionView *collectionView;
15 | @property (nonatomic, strong) NSArray *content;
16 | @property (nonatomic, strong) CustomCollectionViewItem *item;
17 |
18 | @end
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 |
24 | CustomCollectionViewItem *item = [[CustomCollectionViewItem alloc] initWithNibName:@"CustomCollectionViewItem" bundle:nil];
25 | [item itemClickHandler:^(NSString *title) {
26 | NSLog(@"点击了 %@", title);
27 | }];
28 | self.item = item;
29 | self.collectionView.itemPrototype = self.item;
30 | self.collectionView.content = self.content;
31 |
32 | [self.view addSubview:self.collectionView];
33 | }
34 |
35 | - (NSCollectionView *)collectionView {
36 | if (!_collectionView) {
37 | _collectionView = [[NSCollectionView alloc] initWithFrame:self.view.bounds];
38 | [_collectionView setAutoresizingMask:YES];
39 | [_collectionView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
40 | }
41 | return _collectionView;
42 | }
43 |
44 | - (NSArray *)content {
45 | if (!_content) {
46 | _content = @[@{@"title": @"Computer", @"image": [NSImage imageNamed:NSImageNameComputer]},
47 | @{@"title": @"Folder", @"image": [NSImage imageNamed:NSImageNameFolder]},
48 | @{@"title": @"Network", @"image": [NSImage imageNamed:NSImageNameNetwork]},
49 | @{@"title": @"ColorPanel", @"image": [NSImage imageNamed:NSImageNameColorPanel]},
50 | @{@"title": @"FontPanel", @"image": [NSImage imageNamed:NSImageNameFontPanel]},
51 | @{@"title": @"UserGroup", @"image": [NSImage imageNamed:NSImageNameUserGroup]}];
52 | }
53 | return _content;
54 | }
55 |
56 | @end
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/基本控件(NSCollectionView)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSDatePicker)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | }
21 |
22 | - (IBAction)dateChangeAction:(NSDatePicker *)sender {
23 | NSLog(@"-------: %@", sender.dateValue);
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSDatePicker)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSMenu)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @property (weak) IBOutlet NSMenu *dockMenu;
14 |
15 | @end
16 |
17 | @implementation AppDelegate
18 |
19 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
20 | // Insert code here to initialize your application
21 | }
22 |
23 | - (NSMenu *)applicationDockMenu:(NSApplication *)sender {
24 | return self.dockMenu;
25 | }
26 |
27 | - (IBAction)dockItem1Action:(id)sender {
28 | NSLog(@"Dock菜单: item1");
29 | }
30 |
31 | - (IBAction)dockItem2Action:(id)sender {
32 | NSLog(@"Dock菜单: item2");
33 | }
34 |
35 | - (IBAction)dockItem3Action:(id)sender {
36 | NSLog(@"Dock菜单: item3");
37 | }
38 |
39 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
40 | // Insert code here to tear down your application
41 | }
42 |
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/MainWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainWindowController : NSWindowController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/MainWindowController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "MainWindowController.h"
10 |
11 | @interface MainWindowController ()
12 |
13 | @end
14 |
15 | @implementation MainWindowController
16 |
17 | - (void)windowDidLoad {
18 | [super windowDidLoad];
19 |
20 | }
21 |
22 |
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @property (strong) IBOutlet NSMenu *myMenu;
14 | @property (strong) IBOutlet NSMenu *contextMenu;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 | self.view.menu = self.contextMenu; //设置上下文菜单
24 |
25 | }
26 |
27 | - (IBAction)popMenuAciton:(NSButton *)sender {
28 | NSPoint point = sender.frame.origin;
29 | point.x += 30;
30 | point.y -= 10;
31 | [self.myMenu popUpMenuPositioningItem:nil atLocation:point inView:self.view];
32 | }
33 |
34 | - (IBAction)item1Action:(id)sender {
35 | NSLog(@"----弹出式菜单: itme1");
36 | }
37 |
38 | - (IBAction)item2Action:(id)sender {
39 | NSLog(@"----弹出式菜单: itme2");
40 | }
41 |
42 | - (IBAction)item3Action:(id)sender {
43 | NSLog(@"----弹出式菜单: itme3");
44 | }
45 |
46 | - (IBAction)copyAction:(id)sender {
47 | NSLog(@"----上下文菜单: 复制");
48 | }
49 |
50 | - (IBAction)pasteAction:(id)sender {
51 | NSLog(@"----上下文菜单: 粘贴");
52 | }
53 |
54 | @end
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/基本控件(NSMenu)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSOutlineView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 614DC57A1E08CF530071FEA9
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/Node.h:
--------------------------------------------------------------------------------
1 | //
2 | // Node.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Node : NSObject
12 |
13 | @property (nonatomic, strong) NSString *title;
14 | @property (nonatomic, strong) NSMutableArray *childNodes;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/Node.m:
--------------------------------------------------------------------------------
1 | //
2 | // Node.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "Node.h"
10 |
11 | @implementation Node
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSOutlineView)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/20.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSPopover)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/LoginViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // LoginViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LoginViewController : NSViewController
12 |
13 | - (void)closeHandler:(void (^)())closeHandler;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/LoginViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // LoginViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "LoginViewController.h"
10 |
11 | @interface LoginViewController ()
12 |
13 | @property (nonatomic, strong) void (^closeHandler)();
14 |
15 | @end
16 |
17 | @implementation LoginViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do view setup here.
22 | }
23 |
24 | - (IBAction)loginAction:(NSButton *)sender {
25 | if (self.closeHandler == nil) {
26 | return;
27 | }
28 | self.closeHandler();
29 | }
30 |
31 | - (void)closeHandler:(void (^)())closeHandler{
32 | self.closeHandler = closeHandler;
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ShareViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ShareViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ShareViewController : NSViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ShareViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ShareViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ShareViewController.h"
10 |
11 | @interface ShareViewController ()
12 |
13 | @end
14 |
15 | @implementation ShareViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do view setup here.
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ShowViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ShowViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ShowViewController : NSViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ShowViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ShowViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ShowViewController.h"
10 |
11 | @interface ShowViewController ()
12 |
13 | @end
14 |
15 | @implementation ShowViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do view setup here.
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ShowViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "ShareViewController.h"
11 | #import "ShowViewController.h"
12 | #import "LoginViewController.h"
13 |
14 | @interface ViewController ()
15 |
16 | @property (nonatomic, strong) NSPopover *sharePopover;
17 | @property (nonatomic, strong) NSPopover *showPopover;
18 | @property (nonatomic, strong) NSPopover *loginPopover;
19 |
20 | @end
21 |
22 | @implementation ViewController
23 |
24 | - (void)viewDidLoad {
25 | [super viewDidLoad];
26 |
27 | }
28 |
29 | - (IBAction)shareAction:(NSButton *)sender {
30 | [self.sharePopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSRectEdgeMaxY];
31 | }
32 |
33 | - (IBAction)showAction:(NSButton *)sender {
34 | [self.showPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSRectEdgeMinY];
35 | }
36 |
37 | - (IBAction)loginAction:(NSButton *)sender {
38 | [self.loginPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSRectEdgeMinY];
39 | }
40 |
41 | - (NSPopover *)sharePopover {
42 | if (!_sharePopover) {
43 | _sharePopover = [[NSPopover alloc] init];
44 | _sharePopover.contentViewController = [[ShareViewController alloc] initWithNibName:@"ShareViewController" bundle:nil];
45 | _sharePopover.behavior = NSPopoverBehaviorTransient;
46 | }
47 | return _sharePopover;
48 | }
49 |
50 | - (NSPopover *)showPopover {
51 | if (!_showPopover) {
52 | _showPopover = [[NSPopover alloc] init];
53 | _showPopover.contentViewController = [[ShowViewController alloc] initWithNibName:@"ShowViewController" bundle:nil];
54 | _showPopover.behavior = NSPopoverBehaviorSemitransient;
55 | }
56 | return _showPopover;
57 | }
58 |
59 | - (NSPopover *)loginPopover {
60 | if (!_loginPopover) {
61 | _loginPopover = [[NSPopover alloc] init];
62 | LoginViewController *contentVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
63 | __weak __block typeof(self) weakSelf = self;
64 | [contentVC closeHandler:^{
65 | [weakSelf.loginPopover close];
66 | }];
67 | _loginPopover.contentViewController = contentVC;
68 | _loginPopover.behavior = NSPopoverBehaviorApplicationDefined;
69 | }
70 | return _loginPopover;
71 | }
72 |
73 |
74 | @end
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/基本控件(NSPopover)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSSearchFiled)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @property (strong) IBOutlet NSSearchField *searchField;
14 |
15 | @end
16 |
17 | @implementation ViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 |
22 | NSButtonCell *searchCell = [[self.searchField cell] searchButtonCell];
23 | NSButtonCell *cancelCell = [[self.searchField cell] cancelButtonCell];
24 | searchCell.target = self;
25 | cancelCell.target = self;
26 | searchCell.action = @selector(clickSearchButton:);
27 | cancelCell.action = @selector(clickCancelButton:);
28 |
29 | }
30 |
31 | - (void)clickSearchButton:(NSButtonCell *)sender{
32 | NSLog(@"点击了搜索按钮");
33 | }
34 |
35 | - (void)clickCancelButton:(NSButtonCell *)sender{
36 | NSLog(@"点击了取消按钮");
37 | self.searchField.stringValue = @"";
38 | }
39 |
40 | - (IBAction)searchAction:(NSSearchField *)sender {
41 |
42 | NSLog(@"----%@", sender.stringValue);
43 |
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/基本控件(NSSearchFiled)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSSegmentedControl)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | }
21 |
22 | - (IBAction)segmentAction:(NSSegmentedControl *)sender {
23 |
24 | NSLog(@"---- %ld", sender.selectedSegment);
25 |
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/基本控件(NSSegmentedControl)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSSplitView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | /**
13 | * A group of MASConstraint objects
14 | */
15 | @interface MASCompositeConstraint : MASConstraint
16 |
17 | /**
18 | * Creates a composite with a predefined array of children
19 | *
20 | * @param children child MASConstraints
21 | *
22 | * @return a composite constraint
23 | */
24 | - (id)initWithChildren:(NSArray *)children;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint+Private.h
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 29/04/14.
6 | // Copyright (c) 2014 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 |
11 | @protocol MASConstraintDelegate;
12 |
13 |
14 | @interface MASConstraint ()
15 |
16 | /**
17 | * Whether or not to check for an existing constraint instead of adding constraint
18 | */
19 | @property (nonatomic, assign) BOOL updateExisting;
20 |
21 | /**
22 | * Usually MASConstraintMaker but could be a parent MASConstraint
23 | */
24 | @property (nonatomic, weak) id delegate;
25 |
26 | /**
27 | * Based on a provided value type, is equal to calling:
28 | * NSNumber - setOffset:
29 | * NSValue with CGPoint - setPointOffset:
30 | * NSValue with CGSize - setSizeOffset:
31 | * NSValue with MASEdgeInsets - setInsets:
32 | */
33 | - (void)setLayoutConstantWithValue:(NSValue *)value;
34 |
35 | @end
36 |
37 |
38 | @interface MASConstraint (Abstract)
39 |
40 | /**
41 | * Sets the constraint relation to given NSLayoutRelation
42 | * returns a block which accepts one of the following:
43 | * MASViewAttribute, UIView, NSValue, NSArray
44 | * see readme for more details.
45 | */
46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
47 |
48 | /**
49 | * Override to set a custom chaining behaviour
50 | */
51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
52 |
53 | @end
54 |
55 |
56 | @protocol MASConstraintDelegate
57 |
58 | /**
59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
61 | */
62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
63 |
64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * When you are debugging or printing the constraints attached to a view this subclass
13 | * makes it easier to identify which constraints have been created via Masonry
14 | */
15 | @interface MASLayoutConstraint : NSLayoutConstraint
16 |
17 | /**
18 | * a key to associate with this constraint
19 | */
20 | @property (nonatomic, strong) id mas_key;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASLayoutConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASLayoutConstraint.h"
10 |
11 | @implementation MASLayoutConstraint
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | //
2 | // Masonry.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Masonry.
12 | FOUNDATION_EXPORT double MasonryVersionNumber;
13 |
14 | //! Project version string for Masonry.
15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
16 |
17 | #import "MASUtilities.h"
18 | #import "View+MASAdditions.h"
19 | #import "View+MASShorthandAdditions.h"
20 | #import "ViewController+MASAdditions.h"
21 | #import "NSArray+MASAdditions.h"
22 | #import "NSArray+MASShorthandAdditions.h"
23 | #import "MASConstraint.h"
24 | #import "MASCompositeConstraint.h"
25 | #import "MASViewAttribute.h"
26 | #import "MASViewConstraint.h"
27 | #import "MASConstraintMaker.h"
28 | #import "MASLayoutConstraint.h"
29 | #import "NSLayoutConstraint+MASDebugAdditions.h"
30 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand array additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface NSArray (MASShorthandAdditions)
18 |
19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
22 |
23 | @end
24 |
25 | @implementation NSArray (MASShorthandAdditions)
26 |
27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
28 | return [self mas_makeConstraints:block];
29 | }
30 |
31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
32 | return [self mas_updateConstraints:block];
33 | }
34 |
35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
36 | return [self mas_remakeConstraints:block];
37 | }
38 |
39 | @end
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * makes debug and log output of NSLayoutConstraints more readable
13 | */
14 | @interface NSLayoutConstraint (MASDebugAdditions)
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | #ifdef MAS_VIEW_CONTROLLER
14 |
15 | @interface MAS_VIEW_CONTROLLER (MASAdditions)
16 |
17 | /**
18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
19 | */
20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom;
26 |
27 |
28 | @end
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/Masonry/ViewController+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "ViewController+MASAdditions.h"
10 |
11 | #ifdef MAS_VIEW_CONTROLLER
12 |
13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions)
14 |
15 | - (MASViewAttribute *)mas_topLayoutGuide {
16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
17 | }
18 | - (MASViewAttribute *)mas_topLayoutGuideTop {
19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
20 | }
21 | - (MASViewAttribute *)mas_topLayoutGuideBottom {
22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
23 | }
24 |
25 | - (MASViewAttribute *)mas_bottomLayoutGuide {
26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
27 | }
28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop {
29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
30 | }
31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom {
32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
33 | }
34 |
35 |
36 |
37 | @end
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "Masonry.h"
11 |
12 | @interface ViewController ()
13 |
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | NSSplitView *splitView = [[NSSplitView alloc] initWithFrame:self.view.bounds];
22 | splitView.vertical = YES;
23 | splitView.dividerStyle = NSSplitViewDividerStyleThin;
24 |
25 | NSView *leftView = [[NSView alloc] initWithFrame:CGRectZero];
26 | leftView.autoresizingMask = 0;
27 | leftView.autoresizesSubviews = YES;
28 | leftView.wantsLayer = YES;
29 | leftView.layer.backgroundColor = [NSColor darkGrayColor].CGColor;
30 |
31 | NSView *rightView = [[NSView alloc] initWithFrame:CGRectZero];
32 | rightView.autoresizingMask = 0;
33 | rightView.autoresizesSubviews = YES;
34 | rightView.wantsLayer = YES;
35 | rightView.layer.backgroundColor = [NSColor whiteColor].CGColor;
36 |
37 | [splitView addSubview:leftView];
38 | [splitView addSubview:rightView];
39 |
40 | [self.view addSubview:splitView];
41 |
42 | //添加约束
43 | [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
44 | make.width.greaterThanOrEqualTo(@(self.view.bounds.size.width/4));
45 | make.width.lessThanOrEqualTo(@(self.view.bounds.size.width/2));
46 | }];
47 | [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
48 | make.width.greaterThanOrEqualTo(@(self.view.bounds.size.width/2));
49 | make.width.lessThanOrEqualTo(@(self.view.bounds.size.width/4*3));
50 | }];
51 |
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/基本控件(NSSplitView)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSStatusBar)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 61A91FDB1DFFF61700C97A19
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @property (weak) IBOutlet NSWindow *window;
14 | @property (nonatomic, strong) NSStatusItem *statusItem;
15 |
16 | @end
17 |
18 | @implementation AppDelegate
19 |
20 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
21 | // Insert code here to initialize your application
22 |
23 | NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
24 | NSStatusItem *item = [statusBar statusItemWithLength:28];
25 | item.button.image = [NSImage imageNamed:@"arrow.png"];
26 | item.target = self;
27 | item.action = @selector(itemAction);
28 | self.statusItem = item;
29 |
30 | [self.window makeKeyAndOrderFront:self];
31 | }
32 |
33 | - (void)itemAction{
34 | NSLog(@"statusItem clicked.");
35 | [self.window makeKeyAndOrderFront:self];
36 | [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps];
37 |
38 | }
39 |
40 | - (void)applicationWillHide:(NSNotification *)notification{
41 | NSLog(@"%s", __FUNCTION__);
42 | }
43 |
44 | - (void)applicationWillResignActive:(NSNotification *)notification{
45 | NSLog(@"%s", __FUNCTION__);
46 | }
47 |
48 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
49 | NSLog(@"%s", __FUNCTION__);
50 | }
51 |
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSStatusBar)/基本控件/arrow.png
--------------------------------------------------------------------------------
/基本控件(NSStatusBar)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSTabView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | /**
13 | * A group of MASConstraint objects
14 | */
15 | @interface MASCompositeConstraint : MASConstraint
16 |
17 | /**
18 | * Creates a composite with a predefined array of children
19 | *
20 | * @param children child MASConstraints
21 | *
22 | * @return a composite constraint
23 | */
24 | - (id)initWithChildren:(NSArray *)children;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint+Private.h
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 29/04/14.
6 | // Copyright (c) 2014 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 |
11 | @protocol MASConstraintDelegate;
12 |
13 |
14 | @interface MASConstraint ()
15 |
16 | /**
17 | * Whether or not to check for an existing constraint instead of adding constraint
18 | */
19 | @property (nonatomic, assign) BOOL updateExisting;
20 |
21 | /**
22 | * Usually MASConstraintMaker but could be a parent MASConstraint
23 | */
24 | @property (nonatomic, weak) id delegate;
25 |
26 | /**
27 | * Based on a provided value type, is equal to calling:
28 | * NSNumber - setOffset:
29 | * NSValue with CGPoint - setPointOffset:
30 | * NSValue with CGSize - setSizeOffset:
31 | * NSValue with MASEdgeInsets - setInsets:
32 | */
33 | - (void)setLayoutConstantWithValue:(NSValue *)value;
34 |
35 | @end
36 |
37 |
38 | @interface MASConstraint (Abstract)
39 |
40 | /**
41 | * Sets the constraint relation to given NSLayoutRelation
42 | * returns a block which accepts one of the following:
43 | * MASViewAttribute, UIView, NSValue, NSArray
44 | * see readme for more details.
45 | */
46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
47 |
48 | /**
49 | * Override to set a custom chaining behaviour
50 | */
51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
52 |
53 | @end
54 |
55 |
56 | @protocol MASConstraintDelegate
57 |
58 | /**
59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
61 | */
62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
63 |
64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * When you are debugging or printing the constraints attached to a view this subclass
13 | * makes it easier to identify which constraints have been created via Masonry
14 | */
15 | @interface MASLayoutConstraint : NSLayoutConstraint
16 |
17 | /**
18 | * a key to associate with this constraint
19 | */
20 | @property (nonatomic, strong) id mas_key;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASLayoutConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASLayoutConstraint.h"
10 |
11 | @implementation MASLayoutConstraint
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | //
2 | // Masonry.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Masonry.
12 | FOUNDATION_EXPORT double MasonryVersionNumber;
13 |
14 | //! Project version string for Masonry.
15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
16 |
17 | #import "MASUtilities.h"
18 | #import "View+MASAdditions.h"
19 | #import "View+MASShorthandAdditions.h"
20 | #import "ViewController+MASAdditions.h"
21 | #import "NSArray+MASAdditions.h"
22 | #import "NSArray+MASShorthandAdditions.h"
23 | #import "MASConstraint.h"
24 | #import "MASCompositeConstraint.h"
25 | #import "MASViewAttribute.h"
26 | #import "MASViewConstraint.h"
27 | #import "MASConstraintMaker.h"
28 | #import "MASLayoutConstraint.h"
29 | #import "NSLayoutConstraint+MASDebugAdditions.h"
30 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand array additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface NSArray (MASShorthandAdditions)
18 |
19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
22 |
23 | @end
24 |
25 | @implementation NSArray (MASShorthandAdditions)
26 |
27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
28 | return [self mas_makeConstraints:block];
29 | }
30 |
31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
32 | return [self mas_updateConstraints:block];
33 | }
34 |
35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
36 | return [self mas_remakeConstraints:block];
37 | }
38 |
39 | @end
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * makes debug and log output of NSLayoutConstraints more readable
13 | */
14 | @interface NSLayoutConstraint (MASDebugAdditions)
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | #ifdef MAS_VIEW_CONTROLLER
14 |
15 | @interface MAS_VIEW_CONTROLLER (MASAdditions)
16 |
17 | /**
18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
19 | */
20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom;
26 |
27 |
28 | @end
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/Masonry/ViewController+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "ViewController+MASAdditions.h"
10 |
11 | #ifdef MAS_VIEW_CONTROLLER
12 |
13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions)
14 |
15 | - (MASViewAttribute *)mas_topLayoutGuide {
16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
17 | }
18 | - (MASViewAttribute *)mas_topLayoutGuideTop {
19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
20 | }
21 | - (MASViewAttribute *)mas_topLayoutGuideBottom {
22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
23 | }
24 |
25 | - (MASViewAttribute *)mas_bottomLayoutGuide {
26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
27 | }
28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop {
29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
30 | }
31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom {
32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
33 | }
34 |
35 |
36 |
37 | @end
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "Masonry.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property (strong) IBOutlet NSTabView *tabView;
15 |
16 | @end
17 | @implementation ViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 |
22 | //添加随机背景色
23 | for (NSInteger i = 0; i < self.tabView.numberOfTabViewItems; i++) {
24 | NSTabViewItem *item = [self.tabView tabViewItemAtIndex:i];
25 | item.view.wantsLayer = YES;
26 | item.view.layer.backgroundColor = [NSColor colorWithRed:arc4random() % 255 / 255.0
27 | green:arc4random() % 255 / 255.0
28 | blue:arc4random() % 255 / 255.0
29 | alpha:1].CGColor;
30 | }
31 |
32 | //设置代理
33 | self.tabView.delegate = self;
34 |
35 | }
36 |
37 | //添加 item
38 | - (IBAction)addTabItemAction:(NSButton *)sender {
39 | NSString *identifier = [NSString stringWithFormat:@"item%ld", self.tabView.numberOfTabViewItems];
40 | NSTabViewItem *newItem = [[NSTabViewItem alloc] initWithIdentifier:identifier];
41 | newItem.label = identifier;
42 | NSView *itemView = [[NSView alloc] initWithFrame:self.tabView.bounds];
43 | itemView.wantsLayer = YES;
44 | itemView.layer.backgroundColor = [NSColor colorWithRed:arc4random() % 255 / 255.0
45 | green:arc4random() % 255 / 255.0
46 | blue:arc4random() % 255 / 255.0
47 | alpha:1].CGColor;
48 | newItem.view = itemView;
49 | [self.tabView addTabViewItem:newItem];
50 | }
51 |
52 | //删除 item
53 | - (IBAction)deleteItemAction:(NSButton *)sender {
54 | if (self.tabView.numberOfTabViewItems > 0) {
55 | [self.tabView removeTabViewItem:[self.tabView tabViewItemAtIndex:self.tabView.numberOfTabViewItems - 1]];
56 | }
57 | }
58 |
59 | #pragma mark - NSTabViewDelegate
60 |
61 | - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(nullable NSTabViewItem *)tabViewItem{
62 | NSLog(@"label: %@", tabViewItem.label);
63 | NSLog(@"identifier: %@", tabViewItem.identifier);
64 | }
65 |
66 | @end
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/基本控件(NSTabView)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSTableView_ 纯代码)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 611B245B1E022DBB0078BED6
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/CustomTableCellView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTableCellView.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/19.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CustomTableCellView : NSTableCellView
12 |
13 | @property (nonatomic, strong) NSString *string;
14 | @property (nonatomic, strong) NSTextField *label;
15 |
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/CustomTableCellView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTableCellView.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/19.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "CustomTableCellView.h"
10 |
11 | @interface CustomTableCellView ()
12 |
13 |
14 | @end
15 |
16 | @implementation CustomTableCellView
17 |
18 | - (void)setString:(NSString *)string {
19 | NSTextField *label = [[NSTextField alloc] initWithFrame:self.bounds];
20 | label.stringValue = string;
21 | label.editable = NO;
22 | label.bordered = NO;
23 | label.backgroundColor = [NSColor clearColor];
24 | [self addSubview:label];
25 | }
26 |
27 | - (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
28 | {
29 | [super setBackgroundStyle:backgroundStyle];
30 | // if(backgroundStyle == NSBackgroundStyleDark){
31 | self.label.cell.backgroundStyle = NSBackgroundStyleLight;
32 | // }
33 | }
34 |
35 | - (void)drawRect:(NSRect)dirtyRect {
36 | [super drawRect:dirtyRect];
37 |
38 | // Drawing code here.
39 | }
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/CustomTableRowView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTableRowView.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CustomTableRowView : NSTableRowView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/CustomTableRowView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomTableRowView.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "CustomTableRowView.h"
10 |
11 | @implementation CustomTableRowView
12 |
13 | // 自定义 row 被选中的背景色
14 | -(void)drawSelectionInRect:(NSRect)dirtyRect {
15 | if (self.selectionHighlightStyle != NSTableViewSelectionHighlightStyleNone) {
16 | [[NSColor lightGrayColor] setFill];
17 | NSBezierPath *path = [NSBezierPath bezierPathWithRect:NSInsetRect(self.bounds, 0, 0)];
18 | [path fill];
19 | [path stroke];
20 | }
21 | }
22 |
23 | //自定义 row 背景色
24 | - (void)setBackgroundColor:(NSColor *)backgroundColor {
25 | super.backgroundColor = [NSColor whiteColor];
26 | }
27 |
28 | - (void)drawRect:(NSRect)dirtyRect {
29 | [super drawRect:dirtyRect];
30 |
31 | // Drawing code here.
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | /**
13 | * A group of MASConstraint objects
14 | */
15 | @interface MASCompositeConstraint : MASConstraint
16 |
17 | /**
18 | * Creates a composite with a predefined array of children
19 | *
20 | * @param children child MASConstraints
21 | *
22 | * @return a composite constraint
23 | */
24 | - (id)initWithChildren:(NSArray *)children;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint+Private.h
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 29/04/14.
6 | // Copyright (c) 2014 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 |
11 | @protocol MASConstraintDelegate;
12 |
13 |
14 | @interface MASConstraint ()
15 |
16 | /**
17 | * Whether or not to check for an existing constraint instead of adding constraint
18 | */
19 | @property (nonatomic, assign) BOOL updateExisting;
20 |
21 | /**
22 | * Usually MASConstraintMaker but could be a parent MASConstraint
23 | */
24 | @property (nonatomic, weak) id delegate;
25 |
26 | /**
27 | * Based on a provided value type, is equal to calling:
28 | * NSNumber - setOffset:
29 | * NSValue with CGPoint - setPointOffset:
30 | * NSValue with CGSize - setSizeOffset:
31 | * NSValue with MASEdgeInsets - setInsets:
32 | */
33 | - (void)setLayoutConstantWithValue:(NSValue *)value;
34 |
35 | @end
36 |
37 |
38 | @interface MASConstraint (Abstract)
39 |
40 | /**
41 | * Sets the constraint relation to given NSLayoutRelation
42 | * returns a block which accepts one of the following:
43 | * MASViewAttribute, UIView, NSValue, NSArray
44 | * see readme for more details.
45 | */
46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
47 |
48 | /**
49 | * Override to set a custom chaining behaviour
50 | */
51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
52 |
53 | @end
54 |
55 |
56 | @protocol MASConstraintDelegate
57 |
58 | /**
59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
61 | */
62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
63 |
64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * When you are debugging or printing the constraints attached to a view this subclass
13 | * makes it easier to identify which constraints have been created via Masonry
14 | */
15 | @interface MASLayoutConstraint : NSLayoutConstraint
16 |
17 | /**
18 | * a key to associate with this constraint
19 | */
20 | @property (nonatomic, strong) id mas_key;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASLayoutConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASLayoutConstraint.h"
10 |
11 | @implementation MASLayoutConstraint
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | //
2 | // Masonry.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Masonry.
12 | FOUNDATION_EXPORT double MasonryVersionNumber;
13 |
14 | //! Project version string for Masonry.
15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
16 |
17 | #import "MASUtilities.h"
18 | #import "View+MASAdditions.h"
19 | #import "View+MASShorthandAdditions.h"
20 | #import "ViewController+MASAdditions.h"
21 | #import "NSArray+MASAdditions.h"
22 | #import "NSArray+MASShorthandAdditions.h"
23 | #import "MASConstraint.h"
24 | #import "MASCompositeConstraint.h"
25 | #import "MASViewAttribute.h"
26 | #import "MASViewConstraint.h"
27 | #import "MASConstraintMaker.h"
28 | #import "MASLayoutConstraint.h"
29 | #import "NSLayoutConstraint+MASDebugAdditions.h"
30 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand array additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface NSArray (MASShorthandAdditions)
18 |
19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
22 |
23 | @end
24 |
25 | @implementation NSArray (MASShorthandAdditions)
26 |
27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
28 | return [self mas_makeConstraints:block];
29 | }
30 |
31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
32 | return [self mas_updateConstraints:block];
33 | }
34 |
35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
36 | return [self mas_remakeConstraints:block];
37 | }
38 |
39 | @end
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * makes debug and log output of NSLayoutConstraints more readable
13 | */
14 | @interface NSLayoutConstraint (MASDebugAdditions)
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | #ifdef MAS_VIEW_CONTROLLER
14 |
15 | @interface MAS_VIEW_CONTROLLER (MASAdditions)
16 |
17 | /**
18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
19 | */
20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom;
26 |
27 |
28 | @end
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/Masonry/ViewController+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "ViewController+MASAdditions.h"
10 |
11 | #ifdef MAS_VIEW_CONTROLLER
12 |
13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions)
14 |
15 | - (MASViewAttribute *)mas_topLayoutGuide {
16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
17 | }
18 | - (MASViewAttribute *)mas_topLayoutGuideTop {
19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
20 | }
21 | - (MASViewAttribute *)mas_topLayoutGuideBottom {
22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
23 | }
24 |
25 | - (MASViewAttribute *)mas_bottomLayoutGuide {
26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
27 | }
28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop {
29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
30 | }
31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom {
32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
33 | }
34 |
35 |
36 |
37 | @end
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ 纯代码)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/15.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSTableView_CellBased)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 61E2BA151E00E17700302FC7
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @property (strong) IBOutlet NSTableView *tableView;
14 | @property (nonatomic, strong) NSArray *dataSource;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 | [self initData];
24 | self.tableView.delegate = self;
25 | self.tableView.dataSource = self;
26 | }
27 |
28 | - (void)initData{
29 | self.dataSource = @[@{@"name": @"John", @"address": @"USA", @"gender": @"Male", @"married": @(1)},
30 | @{@"name": @"Mary", @"address": @"China", @"gender": @"Female", @"married": @(0)},
31 | @{@"name": @"Jack", @"address": @"Japan", @"gender": @"Male", @"married": @(0)},
32 | @{@"name": @"Tom", @"address": @"Russia", @"gender": @"Male", @"married": @(1)}];
33 | }
34 |
35 | #pragma mark - NSTableViewDataSource
36 |
37 | - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
38 | return self.dataSource.count;
39 | }
40 |
41 | - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
42 | NSDictionary *rowInfoDic = self.dataSource[row];
43 | NSString *rowData = rowInfoDic[tableColumn.identifier];
44 | return rowData;
45 | }
46 |
47 | @end
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_CellBased)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSTableView_ViewBased)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 61E2BA151E00E17700302FC7
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTableView_ViewBased)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/14.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSTextField & NSTextView)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @property (strong) IBOutlet NSTextField *textField;
14 | @property (strong) IBOutlet NSTextView *textView;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 | self.textField.delegate = self;
24 | self.textView.delegate = self;
25 |
26 | }
27 |
28 | #pragma mark - NSTextFieldDelegate
29 |
30 | - (void)controlTextDidChange:(NSNotification *)obj {
31 | NSLog(@"%s", __FUNCTION__);
32 | if (self.textField == obj.object) {
33 | NSLog(@"----------%@", self.textField.stringValue);
34 | }
35 | }
36 |
37 | - (void)controlTextDidEndEditing:(NSNotification *)obj {
38 | NSLog(@"%s", __FUNCTION__);
39 | }
40 |
41 | - (void)controlTextDidBeginEditing:(NSNotification *)obj {
42 | NSLog(@"%s", __FUNCTION__);
43 | }
44 |
45 | #pragma mark - NSTextViewDelegate
46 |
47 | - (BOOL)textShouldBeginEditing:(NSText *)textObject {
48 | return YES;
49 | }
50 |
51 | - (BOOL)textShouldEndEditing:(NSText *)textObject {
52 | return YES;
53 | }
54 |
55 | - (void)textDidBeginEditing:(NSNotification *)notification{
56 | NSLog(@"%s", __FUNCTION__);
57 | }
58 |
59 | - (void)textDidEndEditing:(NSNotification *)notification{
60 | NSLog(@"%s", __FUNCTION__);
61 | }
62 |
63 | - (void)textDidChange:(NSNotification *)notification {
64 | NSLog(@"%s", __FUNCTION__);
65 | self.textView = notification.object;
66 | NSLog(@"~~~~~~~~~~~%@", self.textView.string);
67 | }
68 |
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/基本控件(NSTextField & NSTextView)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(NSToolbar)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/MainWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainWindowController : NSWindowController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/MainWindowController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/13.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "MainWindowController.h"
10 |
11 | @interface MainWindowController ()
12 |
13 | @end
14 |
15 | @implementation MainWindowController
16 |
17 | - (void)windowDidLoad {
18 | [super windowDidLoad];
19 | // self.window.titleVisibility = NSWindowTitleHidden;
20 | }
21 | - (IBAction)open:(NSToolbarItem *)sender {
22 | NSLog(@"-------Open");
23 | }
24 |
25 | //-(BOOL)validateToolbarItem:(NSToolbarItem *)item{
26 | // if ([item.itemIdentifier isEqualToString:@"Open"]) {
27 | // return NO;
28 | // }
29 | // return YES;
30 | //}
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | }
21 |
22 |
23 | @end
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/基本控件(NSToolbar)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/基本控件(Radio)/基本控件.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 基本控件.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905781DFE7209001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18 | // Insert code here to initialize your application
19 | }
20 |
21 |
22 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
23 | // Insert code here to tear down your application
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : NSViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @property (strong) IBOutlet NSButton *radio1;
14 | @property (strong) IBOutlet NSButton *radio2;
15 | @property (strong) IBOutlet NSButton *radio3;
16 |
17 | @end
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 |
24 | }
25 |
26 | - (IBAction)radioAction:(NSButton *)sender {
27 | self.radio1.state = 0;
28 | self.radio2.state = 0;
29 | self.radio3.state = 0;
30 | NSButton *radio = sender;
31 | radio.state = !radio.state;
32 | }
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/基本控件(Radio)/基本控件/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 基本控件
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/模态窗口/模态窗口.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/模态窗口/模态窗口.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 模态窗口.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 616905561DFE4A3B001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 模态窗口
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 模态窗口
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ModeWindow.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @property (weak) IBOutlet NSWindow *window;
15 | @property (nonatomic, strong) ModeWindow *modeWindow;
16 |
17 | @end
18 |
19 | @implementation AppDelegate
20 |
21 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
22 | // Insert code here to initialize your application
23 | [self.window center];
24 | }
25 |
26 | - (IBAction)showModeWindow:(NSButton *)sender {
27 |
28 | //模态显示时, 关闭窗口后需要调用结束模态展示的方法
29 | // [[NSApplication sharedApplication] runModalForWindow:self.modeWindow];
30 |
31 | //一般显示
32 | [self.modeWindow makeKeyAndOrderFront:self];
33 | }
34 |
35 | - (ModeWindow *)modeWindow{
36 | if (!_modeWindow) {
37 | NSNib *nib = [[NSNib alloc] initWithNibNamed:@"ModeWindow" bundle:nil];
38 | NSArray *objects;
39 | if ([nib instantiateWithOwner:self topLevelObjects:&objects]) {
40 | for (id obj in objects) {
41 | if ([obj isKindOfClass:[ModeWindow class]]) {
42 | _modeWindow = obj;
43 | break;
44 | }
45 | }
46 | }
47 | [_modeWindow center];
48 | _modeWindow.restorable = NO;
49 | _modeWindow.delegate = self;
50 | }
51 | return _modeWindow;
52 | }
53 |
54 | - (void)windowWillClose:(NSNotification *)notification{
55 | //结束模态显示
56 | // [[NSApplication sharedApplication] stopModal];
57 | }
58 |
59 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
60 | // Insert code here to tear down your application
61 | }
62 |
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/模态窗口/模态窗口/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/ModeWindow.h:
--------------------------------------------------------------------------------
1 | //
2 | // ModeWindow.h
3 | // 模态窗口
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ModeWindow : NSWindow
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/ModeWindow.m:
--------------------------------------------------------------------------------
1 | //
2 | // ModeWindow.m
3 | // 模态窗口
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "ModeWindow.h"
10 |
11 | @implementation ModeWindow
12 |
13 | - (IBAction)cancelAction:(NSButton *)sender {
14 | [self close];
15 | }
16 |
17 | - (IBAction)okAction:(NSButton *)sender {
18 | [self close];
19 | }
20 |
21 |
22 | - (void)dealloc{
23 | NSLog(@"释放 window");
24 | }
25 | @end
26 |
--------------------------------------------------------------------------------
/模态窗口/模态窗口/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 模态窗口
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitHubWanglei/macOS_AppKit_Demo/8a8176d684bbb6050f20757431964af37b1db783/自定义面板/自定义面板.xcodeproj/project.xcworkspace/xcuserdata/lihongfeng.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/自定义面板/自定义面板.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板.xcodeproj/xcuserdata/lihongfeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | 自定义面板.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 6169052A1DFE3BAC001BB03B
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "MainWindowController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @property (nonatomic, strong) MainWindowController *mainwindowController;
15 |
16 | @end
17 |
18 | @implementation AppDelegate
19 |
20 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
21 | // Insert code here to initialize your application
22 | [self.mainwindowController showWindow:self];
23 | }
24 |
25 | - (MainWindowController *)mainwindowController{
26 | if (!_mainwindowController) {
27 | _mainwindowController = [[MainWindowController alloc] init];
28 | }
29 | return _mainwindowController;
30 | }
31 |
32 | - (void)applicationWillTerminate:(NSNotification *)aNotification {
33 | // Insert code here to tear down your application
34 | }
35 |
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/自定义面板/自定义面板/CustomPanel.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomPanel.h
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CustomPanel : NSPanel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/CustomPanel.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomPanel.m
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "CustomPanel.h"
10 |
11 | @implementation CustomPanel
12 |
13 | - (IBAction)cancelAction:(NSButton *)sender {
14 | [self.parentWindow endSheet:self returnCode:1];
15 | }
16 |
17 | - (IBAction)okAction:(NSButton *)sender {
18 | [self.parentWindow endSheet:self returnCode:2];
19 | }
20 |
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2016年 wanglei. All rights reserved.
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : NSViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 | #import "CustomPanel.h"
11 |
12 | @interface MainViewController ()
13 |
14 | @property (nonatomic, strong) CustomPanel *panel;
15 |
16 | @end
17 |
18 | @implementation MainViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | // Do view setup here.
23 |
24 | }
25 |
26 | - (IBAction)showCustomPanelAction:(NSButton *)sender {
27 | self.panel.parentWindow = self.view.window;
28 | [self.view.window beginSheet:self.panel completionHandler:^(NSModalResponse returnCode) {
29 | NSLog(@"returnCode: %ld", (long)returnCode);
30 | if (returnCode == 1) {
31 | NSLog(@"取消");
32 | }else{
33 | NSLog(@"确定");
34 | }
35 | }];
36 | }
37 |
38 | - (CustomPanel *)panel {
39 | if (!_panel) {
40 | NSNib *nib = [[NSNib alloc] initWithNibNamed:@"CustomPanel" bundle:nil];
41 | NSArray *topLevelObjects;
42 | if ([nib instantiateWithOwner:self topLevelObjects:&topLevelObjects]) {
43 | for (id object in topLevelObjects) {
44 | if ([object isKindOfClass:[CustomPanel class]]) {
45 | _panel = object;
46 | break;
47 | }
48 | }
49 | }
50 | _panel.restorable = NO;
51 | [_panel center];
52 | }
53 | return _panel;
54 | }
55 |
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.h
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainWindowController : NSWindowController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainWindowController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.m
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import "MainWindowController.h"
10 | #import "MainViewController.h"
11 |
12 | @interface MainWindowController ()
13 |
14 | @end
15 |
16 | @implementation MainWindowController
17 |
18 | - (void)windowDidLoad {
19 | [super windowDidLoad];
20 |
21 | self.window.restorable = NO;
22 | [self.window center];
23 | self.window.contentViewController = [[MainViewController alloc] init];
24 | }
25 |
26 | - (NSString *)windowNibName{
27 | return @"MainWindowController";
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/MainWindowController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/自定义面板/自定义面板/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // 自定义面板
4 | //
5 | // Created by lihongfeng on 16/12/12.
6 | // Copyright © 2016年 wanglei. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, const char * argv[]) {
12 | return NSApplicationMain(argc, argv);
13 | }
14 |
--------------------------------------------------------------------------------