美文网首页
swift 适配问题 -------(项目准备-学习2)

swift 适配问题 -------(项目准备-学习2)

作者: 奔跑吧小蚂蚁 | 来源:发表于2019-03-12 18:53 被阅读0次

兵马未动粮草先行,关于swife适配我完全将自己在OC中的逻辑搬了过了,个人喜欢对状态栏进行直接判断 判断状态栏的高度,直接对新老机型进行适配,比较节省代码,直接上代码,希望对你有用。

//
//  Screen.swift
//  BTC
//
//  Created by 智创 on 2019/3/12.
//  Copyright © 2019年 智创. All rights reserved.
//

import UIKit

public let screen_bounds = UIScreen.main.bounds
public let screen_size = UIScreen.main.bounds.size
public let screen_width = UIScreen.main.bounds.size.width
public let screen_height = UIScreen.main.bounds.size.height

public let statusBar_height = UIApplication.shared.statusBarFrame.size.height
public let  nav_content_height = CGFloat(44.0)
public let navBar_height = (UIApplication.shared.statusBarFrame.size.height + 44.0)
public let tabbar_height = (UIApplication.shared.statusBarFrame.size.height)>20.1 ? 83.0:49.0
public let tabbarArc_height = (UIApplication.shared.statusBarFrame.size.height)>20.1 ? 34.0:0.0


/**
 获取频幕的比列 X Y 高度宽度比例值
 */
public func XReal(x:CGFloat) ->CGFloat {
    return x/375 * screen_width
}

public func YReal(y:CGFloat) ->CGFloat {
    return y/667 * screen_height
}

public func WReal(width:CGFloat) ->CGFloat {
    return width/375 * screen_width
}

public func HReal(height:CGFloat) ->CGFloat {
    return height/667 * screen_height
}

swift UITabBarController -------(项目准备-学习1)

相关文章

网友评论

      本文标题:swift 适配问题 -------(项目准备-学习2)

      本文链接:https://www.haomeiwen.com/subject/qwtopqtx.html