// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
UIBezierPath *path = [UIBezierPath bezierPath];
//画图的起点坐标
[path moveToPoint:CGPointMake(50, 50)];
//依次连接各个坐标
[path addLineToPoint:CGPointMake(50, 100)];
[path addLineToPoint:CGPointMake(100, 100)];
[path addLineToPoint:CGPointMake(100, 50)];
//闭合
[path closePath];
//上下文
CGContextRef context = UIGraphicsGetCurrentContext();
//保存上下文状态
CGContextSaveGState(context);