LoginSignup
0
0

More than 1 year has passed since last update.

【SwiftUI】図形の表示

Last updated at Posted at 2022-06-29

カプセル型

Simulator Screen Shot - iPhone 12 - 2022-06-29 at 15.57.32.png

import SwiftUI

struct ContentView: View {
    var body: some View {
        Capsule()
            .frame(width: 100, height: 50)
    }
}

円形

Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.00.15.png

import SwiftUI

struct ContentView: View {
    var body: some View {
        Circle()
            .frame(width: 100, height: 100)
    }
}

コンテナ相対型

おそらく、ウィジェット用のViewです。
アプリ内で使用すると長方形と同じ見た目になります。

アプリ内 ウィジェット
Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.02.42.png Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.28.46.png
import SwiftUI

struct ContentView: View {
    var body: some View {
        ContainerRelativeShape()
            .frame(width: 100, height: 50)
    }
}

楕円形

Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.05.06.png

import SwiftUI

struct ContentView: View {
    var body: some View {
        Ellipse()
            .frame(width: 100, height: 50)
    }
}

長方形

Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.02.42.png

import SwiftUI

struct ContentView: View {
    var body: some View {
        Rectangle()
            .frame(width: 100, height: 50)
    }
}

角丸長方形

Simulator Screen Shot - iPhone 12 - 2022-06-29 at 16.10.27.png

import SwiftUI

struct ContentView: View {
    var body: some View {
        RoundedRectangle(cornerRadius: 10)
            .frame(width: 100, height: 50)
    }
}
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