LoginSignup
12
9

More than 5 years have passed since last update.

Touchbarアプリを作ってみる

Last updated at Posted at 2017-11-06

動機

普段使わない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から消えてしまうんですよねー…バグなのか何なのか。分かる方がいらっしゃいましたらコメント等で教えてくださると有難いです😭😭😭

12
9
0

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
  3. You can use dark theme
What you can do with signing up
12
9