// // DeviceInfoView.swift // SwiftUIDemo // // Created by shiyanjun on 2023/2/12. // import SwiftUI struct DeviceInfoView: View { let screenSize: CGSize = UIScreen.main.bounds.size let device: UIDevice = UIDevice.current var body: some View { VStack(alignment: .leading, spacing: 10) { Text("屏幕宽度:\(screenSize.width)") // 屏幕宽度:430.000000 Text("屏幕高度:\(screenSize.height)") // 屏幕高度:932.000000 Text("设备名称:\(device.name)") // 设备名称:iPhone 14 Pro Max Text("系统名称:\(device.systemName)") // 系统名称:iOS Text("系统版本:\(device.systemVersion)")// 系统版本:16.2 Text("设备型号:\(device.model)") // 设备型号:iPhone } .padding() .background(.orange) .cornerRadius(10) } } struct DeviceInfoView_Previews: PreviewProvider { static var previews: some View { DeviceInfoView() } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter