import "TestView.h"
@implementation TestView
(CGFloat)distanceFromPointX:(CGPoint)start distanceToPointY:(CGPoint)end{
CGFloat distance;
CGFloat xDist = (end.x - start.x);
CGFloat yDist = (end.y - start.y);
distance = sqrt((xDist * xDist) + (yDist * yDist));
return distance;
}(instancetype)initWithFirstView:(UIView *)view1 secondView:(UIView *)view2{
CGFloat length = view2.center.x - view1.center.x;
CGFloat height = view1.center.y - view2.center.y;
float distance = [self distanceFromPointX:view1.center distanceToPointY:view2.center];
CGFloat bottomLine1 = view1.bounds.size.width/2/distance * length;
CGFloat bottomLine2 = view2.bounds.size.width/2/distance * length;
CGFloat bottomline = (length - bottomLine1 - bottomLine2)/2;
CGFloat bottomCenterX = view1.center.x + bottomLine1 + bottomline;
self = [super initWithFrame:CGRectMake(bottomCenterX, 0, 1, 600)];
[self setBackgroundColor:[UIColor redColor]];
return self;
}
@end