swift 字体自适应,宽高自适应

let kScreenWidth = UIScreen.main.bounds.width

let kScreenHeight = UIScreen.main.bounds.height



public func FitWidth(_ width: CGFloat) -> CGFloat {

    return width * kScreenWidth / 375.0

}

 

public func FitHeight(_ height: CGFloat) -> CGFloat {

    return height * kScreenHeight / 667.0

}

 

public func FitFont(_ font: CGFloat) -> UIFont {

    return UIFont(name: "PingFangSC-Regular", size: font * kScreenWidth / 375.0)!

}

 

posted @ 2018-08-16 11:22  milaliu99  Views(1192)  Comments(0)    收藏  举报