0
0

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 3 years have passed since last update.

SwiftUIで画像を表示する(画像の切り抜きと影)

Last updated at Posted at 2020-05-04

##画像を追加する

swiftUIを使って画像のようなものを作成する。
2020-05-04 9.56のイメージ.jpg

import SwiftUI

struct CircleImage: View {
    var body: some View {
        Image("8D23A0D7-AB6F-477F-BDED-00D4C8804B99_1_105_c")
        .resizable()
        .clipShape(Circle())
        .overlay(
            Circle().stroke(Color.gray, lineWidth: 4))
            .aspectRatio(contentMode: .fit)
        .shadow(radius: 10)
    }
}

struct CircleImage_Previews: PreviewProvider {
    static var previews: some View {
        CircleImage()
    }
}

お決まりの
var body: some View { }
のなかにimage("")とすることで簡単に画像を追加することができる。
切り抜くのはclipShape()で、今回はCircle()としている。
shadow(radius: )で影をつけている。
resizable()で画面サイズに合わせて収縮させている。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?