表格1-邊框制作
制作表格常用:
以UILabel為例:
//邊框顏色,要為CGColor
lable.layer.borderColor = RGBColor(179, 219, 200, 1.0).CGColor;//RGBColor自定義顏色
//邊框?qū)挾?lable.layer.borderWidth = 1;
以UIButton為例:
[self.tableBtn.layer setBorderColor:RGBColor(179, 219, 200, 1.0).CGColor];
[self.tableBtn.layer setBorderWidth:1];
[self.tableBtn.layer setMasksToBounds:YES];
//表格1-繪圖-就是畫線
需要循環(huán)創(chuàng)建算坐標(biāo)點(diǎn)進(jìn)行
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 1.0);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGPoint aPoints[5];
aPoints[0] =CGPointMake(0, 0);
aPoints[1] =CGPointMake(CGRectGetWidth(rect), 0);
aPoints[2] =CGPointMake(CGRectGetWidth(rect), CGRectGetHeight(rect));
aPoints[3] =CGPointMake(0, CGRectGetHeight(rect));
aPoints[4] =CGPointMake(0, 0);
CGContextAddLines(context, aPoints, 5);
CGContextDrawPath(context, kCGPathStroke);
}
//RGBColor自定義的宏
#define RGBColor(_R_,_G_,_B_,_alpha_) [UIColor colorWithRed:_R_/255.0 green:_G_/255.0 blue:_B_/255.0 alpha:_alpha_]
//自定義顏色(十六進(jìn)制)
#define RGBSixteenColor(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]