LoginSignup
9

More than 5 years have passed since last update.

posted at

updated at

Touchbarアプリを作ってみる

動機

普段使わないTouchbarの有効活用したかった()

注意:Swift初心者です。お見苦しい所があるかもしれません。お許し下さい。

開発環境

Xcode 9.2 beta (9C32c)/Swift4

XcodeProgectの作成

1.CocoaAppを選択
image.png

2.Main.storyboardを選択

3.NSTouchBarをViewControllerにドラッグ&ドロップ
Main_storyboard.png

4.ButtonまたはLabelを選択,配置
image.png

5.新しいViewControllerを作成

私の場合、WindowControllerファイルを作りました。

6.コードの記述

NSWindowControllerを追記

WindowController_swift.png

面倒くさいのでControlキーを押しながらドラッグ&ドロップ
Banners_and_Alerts_と_WindowController_swift_—_Edited_と_WindowController_swift.png

ConnectionはActionを選択、Nameは適当にどうぞ。
image.png

あとは中身の記述をするだけです。

WindowController_swift.png

実行

Screen Recording 2017-11-06 at 10.59 午後.gif

以上になります。

追記

何故かわからないんですが、一度RunするごとにNSTouchBarがStoryboardから消えてしまうんですよねー…バグなのか何なのか。分かる方がいらっしゃいましたらコメント等で教えてくださると有難いです😭😭😭

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
9