Sagit.Framework For IOS automatic layout tutorial: 11, common macro definition: frame coordinate system, get UI, UI value, font color, picture

Time:2020-10-24

preface:

This article introduces some SAGIT framework definitions, commonly used macro definitions.

1. Coordinate system correlation

//Full screen
#define STFullRect [UIScreen mainScreen].bounds
#define STFullSize [UIScreen mainScreen].bounds.size
//Empty screen
#define STEmptyRect CGRectMake(0,0,0,0)

//Coordinate system
#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 STRectCopy(frame) CGRectMake(frame.origin.x,frame.origin.y, frame.size.width, frame.size.height);

2. Uiview view view: getting

//! define a layout ID that can be used in both view and controller
#define sagit self.baseView

#endif

//Shorthand for the previous UI control
#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)
//Get control
#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. The value of UI.

//Get UI value
# 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. Font and color

//Font pixels
#define STFont(px) [UIFont systemFontOfSize:px*Ypt]
//Bold
#define STFontBold(px) [UIFont boldSystemFontOfSize:px*Ypt]
#Pragma mark color

//Equipment color
#Define stdevicecolor [uicolor hex: @ "f4f4f4f4"] // beibai
//Color
#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. Pictures

//Pictures
#define STImage(imgName) [UIImage imageNamed:imgName]
#define STImageOriginal(imgName) [[UIImage imageNamed:imgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

 

Summary:

Look back to yourself: the definition in stdefineui. H.