swift宏定义与枚举

swift中的枚举:

enum CompassPoint { 
 case North
 case South
 case East 
 case West
}

swift中的宏定义:


public let ScreenWidth = UIScreen.mainScreen().bounds.size.width
public let ScreenHeight = UIScreen.mainScreen().bounds.size.height
public let MainBounds = UIScreen.mainScreen().bounds
public let globalTabbarHeight = 49
public let globalNavigationBarHeight = 64

注:public可加可不加

如果有参数:


func RGBCOLOR(r:CGFloat,_ g:CGFloat,_ b:CGFloat) -> UIColor
{
    return UIColor(red: (r)/255.0, green: (g)/255.0, blue: (b)/255.0, alpha: 1.0)
}

你可能感兴趣的:(swift宏定义与枚举)