NYFitReal.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // NYFitReal.swift
  3. // JSJP_Student_sw
  4. //
  5. // Created by Ning.ge on 2023/6/1.
  6. //
  7. import UIKit
  8. struct NYFitReal {
  9. //以iphone6为基础缩放系数
  10. static let screenHeight = UIScreen.main.bounds.height
  11. static let screenWidth = UIScreen.main.bounds.width
  12. //竖屏
  13. static func isPortrait() -> Bool {
  14. let orientation = UIDevice.current.orientation
  15. return orientation.isPortrait
  16. }
  17. //横屏
  18. static func isLandscape() -> Bool {
  19. let orientation = UIDevice.current.orientation
  20. return orientation.isLandscape
  21. }
  22. //根据ip6的屏幕来拉伸宽
  23. static func RealValue(x:CGFloat) -> CGFloat{
  24. return ((x)*((isPortrait() ? screenWidth : screenHeight)/375.0))
  25. }
  26. //根据ip6的屏幕来拉伸宽Int
  27. static func RealValueInt(x:CGFloat) -> Int{
  28. return ((NSInteger)((x)*((isPortrait() ? screenWidth : screenHeight)/375.0)))
  29. }
  30. //iphone14高拉伸
  31. static func RealHeightValue(height:CGFloat) -> CGFloat{
  32. return ((height)*((isPortrait() ? kScreenHeight : screenWidth)/812.0))
  33. }
  34. //iphone6缩放系数
  35. static let Ip6ScaleWidth = screenWidth/375.0
  36. static let Ip6ScaleHeight = screenHeight/667.0
  37. //以iphone14为基础缩放系数
  38. static let Ip14ScaleWidth = screenWidth/375.0
  39. static let Ip14ScaleHeight = screenHeight/812.0
  40. }