Sagit.Framework For IOS 自动布局教程:11、常用宏定义:frame坐标系、获取UI、UI取值、字体颜色、图片

网友投稿 879 2022-11-27

Sagit.Framework For IOS 自动布局教程:11、常用宏定义:frame坐标系、获取UI、UI取值、字体颜色、图片

Sagit.Framework For IOS 自动布局教程:11、常用宏定义:frame坐标系、获取UI、UI取值、字体颜色、图片

前言:

本篇介绍一些Sagit框架定义,常用到的宏定义。

1、坐标系相关

//全屏#define STFullRect [UIScreen mainScreen].bounds#define STFullSize [UIScreen mainScreen].bounds.size//空屏#define STEmptyRect CGRectMake(0,0,0,0)//坐标系#define STRectMake(x,y,width,height) CGRectMake(x*Xpt,y*Ypt,width*Xpt,height*Ypt)#define STSizeMake(width,height) CGSizeMake(width*Xpt,height*Ypt)#define STPointMake(x,y) CGPointMake(x*Xpt,y*Ypt)#define

2、UIView视图:获取

//!定义一个可以在view和Controller中共同使用的布局标识#define sagit self.baseView#endif//上一个UI控件的简写#define STPreView sagit.lastAddView.preView#define STLastView sagit.lastAddView#define STLastControl ((UIControl*)STLastView)#define STLastButton ((UIButton*)STLastView)#define STLastTextField ((UITextField*)STLastView)#define STLastTextView ((UITextView*)STLastView)#define STLastImageView ((UIImageView*)STLastView)#define STLastLabel ((UILabel*)STLastView)#define STLastSwitch ((UISwitch*)STLastView)#define STLastStepper ((UIStepper*)STLastView)#define STLastSlider ((UISlider*)STLastView)#define STLastProgressView ((UIProgressView*)STLastView)#define STLastTableView ((UITableView*)STLastView)#define STLastCollectoinView ((UICollectionView*)STLastView)//获取控件#define STUIView(name) [sagit find:name]#define STSTView(name) ((STView*)STUIView(name))#define STControl(name) ((UIControl*)STUIView(name))#define STButton(name) ((UIButton*)STUIView(name))#define STTextField(name) ((UITextField*)STUIView(name))#define STTextView(name) ((UITextView*)STUIView(name))#define STImageView(name) ((UIImageView*)STUIView(name))#define STLabel(name) ((UILabel*)STUIView(name))#define STSwitch(name) ((UISwitch*)STUIView(name))#define STStepper(name) ((UIStepper*)STUIView(name))#define STSlider(name) ((UISlider*)STUIView(name))#define STProgressView(name) ((UIProgressView*)STUIView(name))#define STTableView(name) ((UITableView*)STUIView(name))#define STCollectionView(name) ((UICollectionView*)STUIView(name))#define STFirstTable ((UITableView*)[sagit firstView:@"UITableView"])#define STFirstCollection ((UICollectionView*)[sagit firstView:@"UICollectionView"])

3、UI的取值。

//获取UI值# define STValue(name) [STUIView(name) stValue]# define STSetValue(name,value) [STUIView(name) stValue:value]# define STSelectValue(name) [STUIView(name) selectValue]# define STSelectText(name) [STUIView(name) selectText]

4、字体与颜色

//字体像素#define STFont(px) [UIFont systemFontOfSize:px*Ypt]//加粗#define STFontBold(px) [UIFont boldSystemFontOfSize:px*Ypt]#pragma mark 颜色//设备颜色#define STDeviceColor [UIColor hex:@"#f4f4f4"]//米白//颜色#define STColor(color) [UIColor hex:color]#define ColorBlack [UIColor blackColor] // 0.0 white#define ColorBlue [UIColor blueColor]#define ColorDarkGray [UIColor darkGrayColor]#define ColorLightGray [UIColor lightGrayColor]#define ColorWhite [UIColor whiteColor]#define ColorGray [UIColor grayColor]#define ColorRed [UIColor redColor]#define ColorGreen [UIColor greenColor]#define ColorCyan [UIColor cyanColor]#define ColorYellow [UIColor yellowColor]#define ColorMagenta [UIColor magentaColor]#define ColorOrange [UIColor orangeColor]#define ColorPurple [UIColor purpleColor]#define ColorBrown [UIColor brownColor]#define ColorClear [UIColor clearColor]#define ColorRGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]#define ColorRandom ColorRGB(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

5、图片

//图片#define STImage(imgName) [UIImage imageNamed:imgName]#define

总结:

回头自己看:STDefineUI.h 中的定义。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:CYQ.Data.Orm.DBFast 新增类介绍(含类的源码及新版本配置工具源码)
下一篇:SpringBoot属性注入的多种方式实例
相关文章

 发表评论

暂时没有评论,来抢沙发吧~