iOS中简单的画线功能
2018-03-12 本文已影响0人
曾柏超
#import "ZBView.h"
@implementation ZBView
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
// CGContextSetLineCap(context, kCGLineCapRound);
// CGContextSetLineWidth(context, 3); //线宽
// CGContextSetAllowsAntialiasing(context, true);
// CGContextSetRGBStrokeColor(context, 70.0/255.0, 241.0/255.0, 241.0/255.0 , 1.0); //线的颜色
CGContextBeginPath(context);
CGContextMoveToPoint(context, 0, 0); //起点坐标
CGContextAddLineToPoint(context, self.frame.size.width, self.frame.size.height); //终点坐标
CGContextStrokePath(context);
}
@end