今天修改软件UI时候需要画一条直线,先采用了一下的代码:
CGContextRef context =UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColorwhiteColor].CGColor); CGContextSetLineDash(context, 0, lengths,2); CGContextMoveToPoint(context, 10.0, 20.0); CGContextAddLineToPoint(context, 310.0,20.0); CGContextStrokePath(context); CGContextClosePath(context); CGContextRef