swift 一些公共的宏重新定义

//系统版本号

public let K_CLIENT_VERSION = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String

//APPDELEGATE 对象

public let APP_DELEGATE =  UIApplication.sharedApplication().delegate as! AppDelegate

/* 屏幕的宽 */

public let K_SCREEN_WIDTH  = CGFloat(UIScreen.mainScreen().bounds.size.width)

/* 屏幕的高 */

public let K_SCREEN_HEIGHT  = CGFloat(UIScreen.mainScreen().bounds.size.height)

public let K_SCREEN_Y = UIScreen.mainScreen().bounds.origin.y

public let K_SCREEN_X = UIScreen.mainScreen().bounds.origin.x

//导航栏的高度

public let K_NAVIGATION_BAR_HEIGHT = CGFloat(64.0)

//任务栏的高度

public let K_SYSTEM_BAR = CGFloat(20.0)

//tabBar高度

public let K_TABBAR_HRIGHT = CGFloat(49.0)

//判断是不是6Plus

let iPhone6Plus = UIScreen.instancesRespondToSelector(Selector("currentMode")) ? CGSizeEqualToSize(CGSizeMake(1242, 2208), (UIScreen.mainScreen().currentMode?.size)!) :false

//当前系统版本

let  version = (UIDevice.currentDevice().systemVersion as NSString).floatValue

//根据屏幕宽度调整尺寸(以iPhone5尺寸为基准 640)

func AutoSize(i:CGFloat) -> CGFloat {

    return   ceil((((UIScreen.mainScreen().bounds).size.width * 2) / 640) * i)

}

//字体

func K_FONT_SIZE(size:CGFloat) -> UIFont {

   return UIFont.systemFontOfSize(iPhone6Plus ? (size + 1):size)

}

//主题色

func K_COLOR_THEME_COLOR() -> UIColor{

    return LTools.colorWithHexString("d72421")

}

//背景色

func K_COLOR_MAIN_BACKGROUND() -> UIColor{

    return LTools.colorWithHexString("f9f9f9")

}

//字体

func K_COLOR_MAIN_FONT() -> UIColor{

    return LTools.colorWithHexString("333333")

}

原文地址:https://www.cnblogs.com/scycool/p/5756687.html