其实swift没有宏定义这个概念,但是我们可以用其他方法来代替。
如下:创建一个swift file
//返回RGB颜色值
func RGBA (r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat)->UIColor { return UIColor (red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a) }
//返回view的x值
func x(object: UIView)->CGFloat{
return object.frame.origin.x;
}
//返回view的y值
func y(object: UIView)->CGFloat{
return object.frame.origin.y;
}
//返回view的width
func width(object: UIView)->CGFloat{
return object.frame.size.width;
}
//返回view的height
func height (object: UIView)->CGFloat{
return object.frame.size.height;
}
//屏幕宽度
let screen_width = UIScreen.mainScreen().bounds.size.width;
//屏幕高度
let screen_height = UIScreen.mainScreen().bounds.size.height;
*******************************URL的配置等
let kaddress = "http://120.26.141.141:8080/herose/api/"
let kPhotoAddress = "http://120.26.141.141:8080/herose"
/**获取首页菜单列表**/
let kGetMainPageCommItemsUrl = kaddress+"info_getAllInfo.do"