//
//  HeadTipView.m
//  GotoBus
//
//  Created by 包光清 on 2018/6/21.
//

#import "HeadTipView.h"
#import "Vars.h"
#import <PureLayout/PureLayout.h>
#import "RouteLineView.h"
#import "DrawUtils.h"

@implementation HeadTipView


- (void)drawRect:(CGRect)rect {
    
    [[UIColor whiteColor] set];
    
    UIBezierPath *bezierPath =  [UIBezierPath bezierPath];
    
    [bezierPath moveToPoint:CGPointMake(0, 0)];
    
    bezierPath.lineCapStyle = kCGLineCapRound;
    
    bezierPath.lineJoinStyle = kCGLineJoinRound;
    
    [bezierPath addLineToPoint:CGPointMake(0, rect.size.height / 2.0 - 6)];
    
    [bezierPath addCurveToPoint:CGPointMake(0, rect.size.height / 2.0 + 6) controlPoint1:CGPointMake(10, rect.size.height / 2.0 - 6 ) controlPoint2:CGPointMake(10, rect.size.height / 2.0 + 6 )];
    [bezierPath addLineToPoint:CGPointMake(0, rect.size.height)];
    
    [bezierPath addLineToPoint:CGPointMake(rect.size.width, rect.size.height)];
    
    [bezierPath addLineToPoint:CGPointMake(rect.size.width, rect.size.height / 2.0 + 6)];
    
//    [bezierPath addQuadCurveToPoint:CGPointMake(rect.size.width, rect.size.height / 2.0 - 6) controlPoint:CGPointMake(rect.size.width - 12, rect.size.height / 2.0 )];
    
    [bezierPath addCurveToPoint:CGPointMake(rect.size.width, rect.size.height / 2.0 - 6) controlPoint1:CGPointMake(rect.size.width - 10, rect.size.height / 2.0 + 6 ) controlPoint2:CGPointMake(rect.size.width - 10, rect.size.height / 2.0 - 6 )];

    [bezierPath addLineToPoint:CGPointMake(rect.size.width,0)];
    
    [bezierPath addLineToPoint:CGPointMake(0,0)];
    
    [bezierPath addClip];
    
    UIBezierPath *bezierPath1 = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:5];
    
    [bezierPath1 fill];

    UIBezierPath *bezierPath2 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, rect.size.width, 5) byRoundingCorners:UIRectCornerTopRight|UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];

    [[Vars defaultTintColor] setFill];

    [bezierPath2 fill];
    
}


@end
