1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift:NSTabViewControllerのツールバーのアイテムを中央寄せ

Posted at

環境設定のウィンドウを作る時にNSTabViewControllerを使っていたけれど,他のアプリでツールバーのアイテムが中央寄せになっていたのがかっこよかったので真似ようと思い,やり方を調査した

NSTabViewControllerのサブクラス内
override func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
    var array = super.toolbarDefaultItemIdentifiers(toolbar)
    array.insert(NSToolbarItem.Identifier.flexibleSpace, at: 0)
    array.append(NSToolbarItem.Identifier.flexibleSpace)
    return array
}

要は.flexibleSpaceってやつをツールバーのアイテムの両端に足せば良いみたい.

左寄せ状態

スクリーンショット 2020-01-21 23.50.34.png

中央寄せ状態

スクリーンショット 2020-01-21 23.50.56.png

参考

macOS NSTabViewController centered tab icons

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?