123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // NYFitReal.swift
- // JSJP_Student_sw
- //
- // Created by Ning.ge on 2023/6/1.
- //
- import UIKit
- struct NYFitReal {
- //以iphone6为基础缩放系数
- static let screenHeight = UIScreen.main.bounds.height
- static let screenWidth = UIScreen.main.bounds.width
-
- //竖屏
- static func isPortrait() -> Bool {
- let orientation = UIDevice.current.orientation
- return orientation.isPortrait
- }
- //横屏
- static func isLandscape() -> Bool {
- let orientation = UIDevice.current.orientation
- return orientation.isLandscape
- }
- //根据ip6的屏幕来拉伸宽
- static func RealValue(x:CGFloat) -> CGFloat{
- return ((x)*((isPortrait() ? screenWidth : screenHeight)/375.0))
- }
- //根据ip6的屏幕来拉伸宽Int
- static func RealValueInt(x:CGFloat) -> Int{
- return ((NSInteger)((x)*((isPortrait() ? screenWidth : screenHeight)/375.0)))
- }
- //iphone14高拉伸
- static func RealHeightValue(height:CGFloat) -> CGFloat{
- return ((height)*((isPortrait() ? kScreenHeight : screenWidth)/812.0))
- }
-
- //iphone6缩放系数
- static let Ip6ScaleWidth = screenWidth/375.0
- static let Ip6ScaleHeight = screenHeight/667.0
-
- //以iphone14为基础缩放系数
- static let Ip14ScaleWidth = screenWidth/375.0
- static let Ip14ScaleHeight = screenHeight/812.0
-
- }
|