UIAdaptiveKit
image.png
LayoutTool.swift : UI自动布局的便捷方法, 主要有常用的 宽度, 高度, 字体大小设置. 非常用的封装在LayoutTool的struct里面.
LayoutMethod.swift : 为 LayoutTool提供实现的方法
UIDevice+Extension.swift : 为设备提供便捷方法 例如判断机型, 系统类型 等等.
相关代码如下:
LayoutTool.swift
import UIKit
///适配手机和平板的宽度
public func autoWidth(_ width: CGFloat) -> CGFloat {
if UIApplication.shared.statusBarOrientation.isLandscape {
return LayoutMethod.autoLayoutWidth(iPhoneWidth: width)
}else {
return LayoutMethod.autoLayoutHeight(iPhoneHeight: width)
}
}
///适配手机和平板的高度
public func autoHeihgt(_ height: CGFloat) -> CGFloat {
if UIApplication.shared.statusBarOrientation.isLandscape {
return LayoutMethod.autoLayoutHeight(iPhoneHeight: height)
}else {
return LayoutMethod.autoLayoutWidth(iPhoneWidth: height)
}
}
///系统字号
func autoFontSize(_ font: Float) -> UIFont {
let floatSize = UIDevice.isIpad ? font * 1.5 : font
let font : UIFont = UIFont.systemFont(ofSize: CGFloat(floatSize))
return font
}
struct LayoutTool{
///加粗的系统字号
static func autoBoldfontSize(_ font: Float) -> UIFont {
let floatSize = UIDevice.isIpad ? font * 1.5 : font
let font : UIFont = UIFont.boldSystemFont(ofSize: CGFl