0
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 1 year has passed since last update.

【SwiftUI】欠けた円の作り方

Posted at

SwiftUIで欠けた円の作り方を紹介しようと思います。

Xcode Version 14.2

まずは通常の円です。

ContentView.swift
Circle()
    .trim(from: 0, to: 1) // 線のトリム
    .stroke(
        Color.blue,
        style: StrokeStyle(lineWidth: 20)
    )
    .frame(width: 205, height: 205)

スクリーンショット 2023-02-05 13.19.38.png

.trim(from: 0, to: 1)trimの値を変えてみると、欠けた円になります。

ContentView.swift
Circle()
    .trim(from: 0, to: 0.5) // 線のトリム
    .stroke(
        Color.blue,
        style: StrokeStyle(lineWidth: 20)
    )
    .frame(width: 205, height: 205)

スクリーンショット 2023-02-05 13.25.50.png

このようにto: 0.5に変更すると下だけの半円になります。

あとは、欠けさせたいお好きな数値を入れてみて下さい。

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