//获取绘图上下文CGContextRef context=UIGraphicsGetCurrentContext();
//设置粗细CGContextSetLineWidth(context,0.2);
//开始绘图CGContextBeginPath(context);
//移动到开始绘图点CGContextMoveToPoint(context,5,50);
//移动到第二个点CGContextAddLineToPoint(context,self.frame.size.width-5,50);
//关闭路径CGContextClosePath(context);
//设置颜色[[UIColorgrayColor]setStroke];
//绘图CGContextStrokePath(context);
实现
-(void)drawRect:(CGRect)rect{
CGContextRefcontext=UIGraphicsGetCurrentContext();CGContextSetLineWidth(context,0.2);CGContextBeginPath(context);CGContextMoveToPoint(context,5,50);CGContextAddLineToPoint(context,self.frame.size.width-5,50);CGContextClosePath(context);[[UIColorgrayColor]setStroke];CGContextStrokePath(context);}