Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

3/13 旅行先で1時間勝負

Posted at

日付とかは置いといてとりあえず画像2枚とテキストからとりかかった。

View {
    var body: some View {
        ScrollView {
            VStack {
                ZStack{
                    Image("neko1")
                        .scaledToFit()
                        .frame(width: 350, height: 400)
                        .cornerRadius(30)
                    ZStack {
                        RoundedRectangle(cornerRadius: 30)
                            .fill(Color.black.opacity(0.3))
                            .frame(width: 350, height: 100)
                        Text("Hello, world!")
                            .font(.title)
                            .fontWeight(.bold)
                            .foregroundColor(.white)
                    }
                }
                Image("neko1")
                    .scaledToFit()
                    .frame(width: 350, height: 150)
                    .cornerRadius(30)
                
            }
        }
    }
}

現時点での画面
スクリーンショット 2025-03-13 1.23.38.png

目指している画面
IMG_0877.PNG

◾️直面した問題
・VStackとZStackを重ねる順番で混乱する(どっちで括ればいいかわからなくなる)
・画像の下端にRoundedRectangleを重ねたいがやり方を忘れた
・その中にテキストを2段おさめたかったがそれもできなかった
・Spaserとpaddingを混同している(なんか隙間をつくってくれたり埋めたりするやつ)
→過去のUdemyを復習すればすべてわかるはずなので明日以降に見返す

◾️学び
・以下のエラーの意味と対処法を学んだ
「The image set "neko1" references a file "IMG_0799.JPG", but that file does not have a valid extension.」
→画像の拡張子エラー。今回は取り込んだ画像の拡張子がJPEG.で大文字だったためにエラーが起きた。小文字に書き換えたら解消した。

・Image(systemName:)のやつの名前は「SF Symbols(システム標準アイコン)」。
こいつらだけは特別に.imageScale()でサイズを変更できる( .small(小さめ).medium(標準).large(大きめ) )
Assetsに自分で入れた画像のリサイズは以下など。
.resizable()
.scaledToFit() // アスペクト比を維持して拡大・縮小
.frame(width: x00, height: x00) // 任意のサイズに調整

★明日やること
過去にやったUI部品配置の講座のコードを見返して盗めるブロックを探す。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?