4
1

More than 1 year has passed since last update.

お題は不問!Qiita Engineer Festa 2023で記事投稿!

【SwiftUI】ヘルプテキストを表示する方法

Last updated at Posted at 2023-07-11

はじめに

macアプリには、カーソルを合わせるとヘルプテキストが表示する機能があります。この記事では、これを実現させるhelpの使い方を紹介します。

やり方

  1. helpを表示したいViewにhelp(_:)を追加
  2. help(_:)の引数にhelpの内容を記述
struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .help("Hello, world!")
    }
}

おわりに

テキストにカーソルを合わせてしばらくすると、helpの内容が表示されることが確認できます。この記事が参考になったという方は、いいねとフォローしていただけると嬉しいです😆

関連リンク

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