今回は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
はどの方向かを設定するみたいです。
実行結果はこのようになりました。