表格制作-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]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS中的颜色有UIColor、CGColor、CIColor三种,下面对三种颜色分别进行说明: 一、常用的UIC...
    lfp901020阅读 6,731评论 0 7
  • 接下来我们看Base文件夹下的UIKIt文件夹的内容。 1.UIColor+YYAdd 这里看了这个类,里面有许多...
    充满活力的早晨阅读 2,331评论 0 1
  • 1、禁止手机睡眠 [UIApplication sharedApplication].idleTimerDisab...
    小小夕舞阅读 1,507评论 1 1
  • 『导言』 iOS 开发常用宏总结的相关资料,需要的朋友可以参考下。文章中有不足之处请指正!谢谢! OC对象判断是否...
    随心吧阅读 883评论 0 16
  • 他坐在我对面的沙发上,一言不发,眼睛盯着窗外看着,渐渐地似乎是看得入了神,脸上也没有了表情,我顺着玻璃看过去,除了...
    陈恨水阅读 444评论 0 0