0
0

SwiftUiでViewの3D回転してみる

Posted at

今回はViewを3D回転させてみようと思います。
あまり使い所が無さそうですが、頭の片隅にでも入れておけば、何かの役に立つかもしれないですね。

【Xcode】 15.0
【Swift】 5
【iOS】 17

Rotation3dSampleView.swift
struct Rotation3dSampleView: View {
    var body: some View {
        Text("Hello, World!")
            .rotation3DEffect(.degrees(45), axis: (x: 0.0, y: 1.0, z: 0.0)
        )
    }
}

rotation3DEffectを使用すると、実装できます。
第一引数のAngleに角度を設定して、axisはどの方向かを設定するみたいです。
実行結果はこのようになりました。

スクリーンショット 2023-10-15 17.10.23.png

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