表格制作-1

表格1-边框制作

制作表格常用:

以UILabel为例:

//边框颜色,要为CGColor
lable.layer.borderColor = RGBColor(179, 219, 200, 1.0).CGColor;//RGBColor自定义颜色
//边框宽度
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-绘图-就是画线
需要循环创建算坐标点进行

- (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_]

//自定义颜色(十六进制)
#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]

你可能感兴趣的:(表格制作-1)