{"id":282800,"date":"2016-12-21T09:05:11","date_gmt":"2016-12-21T06:05:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282800"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282800","title":{"rendered":"\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 NSTouchBar \u043d\u0430 Swift"},"content":{"rendered":"<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e Apple \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043c\u0438\u0440\u0443 \u043d\u043e\u0432\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043a\u0443 MacBook Pro. \u0418 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0432\u0435\u0436\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u043b\u043e \u0442\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u044f\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043d\u043e\u043f\u043e\u043a \u0432 \u043d\u0435\u0439 \u0443\u0434\u0430\u043b\u0435\u043d \u2013 \u0432\u0435\u0440\u043d\u0435\u0435, \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u043d\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u0442\u0430\u0447 \u044d\u043a\u0440\u0430\u043d. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u044d\u0442\u043e \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u0435\u0434\u044c \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Apple \u0434\u0430\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 API \u0434\u043b\u044f \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 NSTouchBar. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043c\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0432 \u0430\u043f\u0434\u0435\u0439\u0442\u0435 <a href=\"http:\/\/wgames.ssdzoner.com\/go.php?id=FPZKxD\">MaCleaner<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/067\/bec\/2b4\/067bec2b486c412b80170e161f53135b.jpg\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 NSTouchBar.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0d0\/dfe\/4e5\/0d0dfe4e5dc64d339073ec30c649740c.png\"\/><\/p>\n<p>  <b>Application Region<\/b> \u2013 \u044d\u0442\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434 \u043d\u0443\u0436\u0434\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  <b>Control Strip<\/b> \u2013 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u043f\u0430\u043d\u0435\u043b\u044c. \u0421\u044e\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u0445\u043e\u0434 \u0437\u0430\u043a\u0440\u044b\u0442 \u2013 \u043d\u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0438 \u043a\u0430\u043a-\u0442\u043e \u0435\u0449\u0435 \u0435\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043d\u043e\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 NSTouchBar \u2013 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044f\u0440\u043a\u043e\u0441\u0442\u0438, \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>  <b>System Button<\/b> \u2013 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 NSTouchBar \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u0438\u0439 MacBookPro \u0441 \u0442\u0430\u0447\u0431\u0430\u0440\u043e\u043c. \u0412 Xcode \u0435\u0441\u0442\u044c \u0435\u0433\u043e \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Window &gt; Show Touch Bar. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0443 \u0432\u0430\u0448\u0435\u0433\u043e Xcode \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c 8.1, \u0430 \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2013 10.12.1, \u043f\u0440\u0438\u0447\u0435\u043c \u0441 \u0431\u0438\u043b\u0434\u043e\u043c \u043d\u0435 \u043d\u0438\u0436\u0435 16B2657.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u044b \u0443\u0441\u0435\u0440\u0434\u043d\u043e \u0442\u0440\u0443\u0434\u0438\u043b\u0438\u0441\u044c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0447\u0443\u0434\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2013 \u043e\u043d\u043e \u0432\u0438\u0441\u0438\u0442 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0440\u0435, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043e \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043e\u043a\u043d\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u0442\u043e\u0442 \u043f\u0440\u0438\u043a\u0438\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e46\/e7a\/fc4\/e46e7afc4ce242bb97510f7acd1abd05.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/aff\/9fa\/2d1\/aff9fa2d1c3d4ff2b270c40dba6b8d55.png\"\/><br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0433\u043e\u0440\u0435\u043b\u0438\u0441\u044c \u044d\u0442\u0438\u043c \u0447\u0443\u0434\u0435\u0441\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u2013 \u043c\u043e\u0436\u0435\u0442\u0435 <a href=\"https:\/\/yadi.sk\/d\/YkuHglYC32hj77\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c<\/a> \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u0435\u0437 NSTouchBar \u0437\u0434\u0435\u0441\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u043d\u0438\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0430\u043c\u0438.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0432\u0435\u0434\u0435\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 NSTouchBar. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c NSTouchBar \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043d\u0435\u043c \u201cHello World!\u201d. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0430\u0448 MainPopoverController \u0441\u043b\u0435\u0434\u0443\u0449\u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435: <\/p>\n<pre><code>@available(OSX 10.12.1, *) extension MainPopoverController : NSTouchBarDelegate {          override open func makeTouchBar() -&gt; NSTouchBar? {         let touchBar = NSTouchBar()         touchBar.delegate = self         touchBar.customizationIdentifier =  NSTouchBarCustomizationIdentifier(&quot;My First TouchBar&quot;)         touchBar.defaultItemIdentifiers = [NSTouchBarItemIdentifier(&quot;HelloWorld&quot;)]         touchBar.customizationAllowedItemIdentifiers = [NSTouchBarItemIdentifier(&quot;HelloWorld&quot;)]         return touchBar     }      } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 makeTouchBar() \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 NSTouchBar \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442. \u041a\u0430\u0436\u0434\u044b\u0439 NSTouchBar \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 NSTouchBarItem \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e NSTouchBar, \u0437\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c, \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0430\u0448 NSTouchBar \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:<\/p>\n<pre><code>func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -&gt; NSTouchBarItem? {         switch identifier {         case NSTouchBarItemIdentifier(&quot;HelloWorld&quot;):             let customViewItem = NSCustomTouchBarItem(identifier: identifier)             customViewItem.view = NSTextField(labelWithString: &quot;Hello World!&quot;)             return customViewItem         default:             return nil         } }<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c NSTouchBar \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e. \u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 NSCustomTouchBarItem \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0432 \u043d\u0435\u0433\u043e NSTextField \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u201cHello World!\u201d. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u044b\u043c NSTouchBar! \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u2013 \u0438\u2026<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fa0\/0bd\/b13\/fa00bdb13dc24d6bb5124b772e6b4ee4.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a0c\/d94\/598\/a0cd945989e74a20a1ad055a6e147ce1.png\"\/><\/p>\n<p>  \u0413\u0434\u0435 \u0436\u0435 \u043d\u0430\u0448 \u201cHello World!\u201d? \u0410 \u0434\u0435\u043b\u043e \u0432\u043e\u0442 \u0432 \u0447\u0435\u043c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c NSTouchBar \u0432 MainPopoverController, \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043f\u043e\u043f\u043e\u0432\u0435\u0440\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u043e\u043a\u0443\u0441. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u043e\u043f\u043e\u0432\u0435\u0440\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2013 \u0441\u0430\u043c NSView \u0438 CollectionView. \u0423 NSView (\u0438 CollectionView) acceptsFirstResponder \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 false \u2013 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0444\u043e\u043a\u0443\u0441 \u043d\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0438 NSTouchBar \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u041c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0438\u0437 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 NSView \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c acceptsFirstResponder \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b true.<\/p>\n<pre><code>class MainPopoverView: NSView {      override var acceptsFirstResponder: Bool {         get {             return true         }     }    }<\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u043e\u043f\u043e\u0432\u0435\u0440\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bd0\/d2e\/a8e\/bd0d2ea8e83c4b6284a121b4dc420c37.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e4f\/d90\/c53\/e4fd90c533c74d35810e3ddb79448112.png\"\/><\/p>\n<p>  \u041d\u0430\u0448 NSTouchBar \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u044f\u0432\u0438\u043b \u0441\u0435\u0431\u044f \u043c\u0438\u0440\u0443 \u0438 \u0434\u0430\u0436\u0435 \u0441 \u044d\u0442\u0438\u043c \u043c\u0438\u0440\u043e\u043c \u043f\u043e\u0437\u0434\u043e\u0440\u043e\u0432\u0430\u043b\u0441\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c NSTouchBar \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 NSTouchBar \u0432\u0441\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0432\u0438\u043b\u043e \u0435\u0435 \u0444\u043e\u043d\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430. \u0422\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0432\u0441\u0435\u0439 \u0433\u0430\u043b\u0435\u0440\u0435\u0438 \u0432 NSTouchBar \u043c\u0435\u0441\u0442\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c\u044b\u0439 NSScrubber. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u0448 NSTouchBar \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b NSScrubber. <\/p>\n<pre><code>func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -&gt; NSTouchBarItem? {         switch identifier {         case NSTouchBarItemIdentifier(&quot;HelloWorld&quot;):             let scrubberItem = NSCustomTouchBarItem(identifier: identifier)             let scrubber = NSScrubber()             scrubber.scrubberLayout = NSScrubberFlowLayout()             scrubber.register(NSScrubberImageItemView.self, forItemIdentifier: &quot;ScrubberItemIdentifier&quot;)             scrubber.mode = .free             scrubber.selectionBackgroundStyle = .roundedBackground             scrubber.delegate = self             scrubber.dataSource = self             scrubberItem.view = scrubber             return scrubberItem         default:             return nil         } }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c NSScrubber \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 NSScrubberDataSource; \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e \u2013 \u043d\u0430 NSScrubberDelegate, \u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0430 \u0432 NSTouchBar \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 30, \u0438\u043d\u0430\u0447\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c\u0441\u044f) \u2013 \u043d\u0430 NSScrubberFlowLayoutDelegate.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u0449\u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e MainPopoverController:<\/p>\n<pre><code>@available(OSX 10.12.1, *) extension MainPopoverController: NSScrubberDataSource, NSScrubberDelegate, NSScrubberFlowLayoutDelegate {     func numberOfItems(for scrubber: NSScrubber) -&gt; Int {         return wardrobe.wallpapers.count     }          func scrubber(_ scrubber: NSScrubber, viewForItemAt index: Int) -&gt; NSScrubberItemView {         let itemView = scrubber.makeItem(withIdentifier: &quot;ScrubberItemIdentifier&quot;, owner: nil) as! NSScrubberImageItemView         itemView.image = wardrobe.wallpapers[index].picture         return itemView     }          func scrubber(_ scrubber: NSScrubber, didSelectItemAt index: Int) {         scrubber.selectedIndex = -1         if let screen = NSScreen.main() {             do {                 try NSWorkspace.shared().setDesktopImageURL( wardrobe.wallpapers[index].url, for: screen, options: [:])             } catch {                 print(error)             }         }     }          func scrubber(_ scrubber: NSScrubber, layout: NSScrubberFlowLayout, sizeForItemAt itemIndex: Int) -&gt; NSSize {         return NSSize(width: 60, height: 30)     } }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 NSScrubber. \u0412\u0442\u043e\u0440\u043e\u0439 \u2013 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 NSScrubber (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430). \u0422\u0440\u0435\u0442\u0438\u0439 \u2013 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 NSScrubber \u0438 \u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u0442\u043e\u043b. \u041d\u0443 \u0430 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 NSScrubber.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043d\u0430\u0448 NSTouchBar \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3ac\/a9e\/576\/3aca9e5761ef4531b721db836b12c98d.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/73d\/0bb\/c9d\/73d0bbc9d0e04e119410b6d6f55655ac.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <a href=\"https:\/\/yadi.sk\/d\/THRjp5pD32hj7b\">\u0435\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 NSTouchBar<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430. \u041f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0442\u0430\u0447\u0431\u0430\u0440\u0430 \u0438 \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0447\u0435\u043c \u043c\u044b \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c NSTouchBar) <br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u0447\u0438 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0434\u0438\u043a\u043e\u0432\u0438\u043d\u043a\u043e\u0439 \u043e\u0442 Apple!<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/317232\/\"> https:\/\/habrahabr.ru\/post\/317232\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e Apple \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043c\u0438\u0440\u0443 \u043d\u043e\u0432\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043a\u0443 MacBook Pro. \u0418 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0432\u0435\u0436\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u043b\u043e \u0442\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0440\u044f\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043d\u043e\u043f\u043e\u043a \u0432 \u043d\u0435\u0439 \u0443\u0434\u0430\u043b\u0435\u043d \u2013 \u0432\u0435\u0440\u043d\u0435\u0435, \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u043d\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u0442\u0430\u0447 \u044d\u043a\u0440\u0430\u043d. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u044d\u0442\u043e \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u0435\u0434\u044c \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Apple \u0434\u0430\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 API \u0434\u043b\u044f \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 NSTouchBar. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043c\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0432 \u0430\u043f\u0434\u0435\u0439\u0442\u0435 <a href=\"http:\/\/wgames.ssdzoner.com\/go.php?id=FPZKxD\">MaCleaner<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/067\/bec\/2b4\/067bec2b486c412b80170e161f53135b.jpg\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282800","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282800"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282800\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}