// TabLineView.h
#import <UIKit/UIKit.h>
@interface TabLineView : UIView
@end
// TabLineView.m
#import "TabLineView.h"
@interface TabLineView ()
@property (nonatomic,assign) CGFloat lineY;
@property (nonatomic,assign) CGFloat radiu;
@property (nonatomic,assign) CGFloat lineWidth;
@end
@implementation TabLineView
- (void)drawRect:(CGRect)rect
{
_lineWidth = 0.5;
_lineY = rect.size.height - _lineWidth - 49;
_radiu = (rect.size.height - _lineWidth * 2) / 2.0;
UIColor *color = [UIColor lightGrayColor];
[color set];
//1.左边线条
UIBezierPath *path = [UIBezierPath new];
path.lineWidth = self.lineWidth;
path.lineCapStyle = kCGLineCapRound;
path.lineJoinStyle = kCGLineCapRound;
//起点
[path moveToPoint:CGPointMake(0, _lineY)];
//圆心到 左右横线的垂直距离
CGFloat toTop = _radiu - _lineY + _lineWidth;
//勾股定理
CGFloat all = pow(_radiu, 2) - pow(toTop, 2);
//对边长(有两个,所以 * 2)
CGFloat x2 = sqrt(all) * 2;
//线条宽度(视图宽度减去 圆 所占的 宽度 ,除以2 得到 一边的宽度)
CGFloat line1W = (rect.size.width - x2) / 2;
//圆左边点
CGPoint leftPoint = CGPointMake(line1W, _lineY);
[path addLineToPoint:leftPoint];
[path closeP