LoginSignup
2
1

More than 1 year has passed since last update.

【Swift】画面サイズを取得

Last updated at Posted at 2022-06-22
swift
let bounds = UIScreen.main.bounds
bounds.size  //画面サイズ
bounds.height//高さ
bounds.width //

もう一つの方法

swift
var body: some View {
        GeometryReader { geometry in
            HStack(spacing: 0) {
                Text("Left")
                    .frame(width: geometry.size.width / 2, height: 50)
                    .background(Color.green)
                Text("Right")
                    .frame(width: geometry.size.width / 2, height: 50)
                    .background(Color.blue)
                }
        }
}
2
1
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
2
1