Swiftpack.co - Package - urushiyama/YUPreviewDevice.framework

YUPreviewDevice

Add pre-defined preview devices for SwiftUI.

GitHub release (latest by date) LICENSE Platform Total Download of All Releases Twitter Follow

Install

  • From Swift Package Manager:
  1. Select File > Swift Packages > Add Package Dependency... in Menu Bar of Xcode.
  2. Enter https://github.com/urushiyama/YUPreviewDevice in the text field and press "Next".
  3. Select versions/branches what you want to install and press "Next".
  4. Press "Finish".

Usage

  • Show latest iOS devices with defferent ratio as SwiftUI Previews:
struct YourSwiftUIView_Previews: PreviewProvider {
  static var previews: some View {
    ForEach(PreviewDevice.Product.latest_iOS_devices_with_defferent_ratio) { device in
      YourSwiftUIView()
        .previewDevice(PreviewDevice(rawValue: device.name))
        .previewDisplayName(device.name)
    }
  }
}
  • Show specific preview:
struct YourSwiftUIView_Previews: PreviewProvider {
  static var previews: some View {
    YourSwiftUIView()
      .previewDevice(PreviewDevice.iPhone_11_Pro_Max)
      .previewDisplayName(PreviewDevice.iPhone_11_Pro_Max.rawValue)
  }
}

Complete list of pre-defined devices can be found here.

Author

Yuta Urushiyama

aswif10flis1ntkb [at] gmail.com

Twitter @YUrushiyama

License

MIT License

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

v1.0.5 - 2020-01-16 00:19:32