How to add borderColor and borderWidth?
How to add borderColor and borderWidth?
I'm so sorry I have no idea how to do it now, maybe I would implement it in a later version.
I'm so sorry I have no idea how to do it now, maybe I would implement it in a later version.
Hello owner :
I add this function for you.
Firstly,add a UIColor property named strokeColor and a CGFloat property named lineWidth in BubbleLayer.h file.
// 路径颜色
@property (nonatomic, strong) UIColor *strokeColor;
// 路径宽度
@property (nonatomic, assign) CGFloat lineWidth;
Secondly, modify the code in BubbleLayer.m file.
Specific modification as follows:
// 生成用于mask的layer
- (CAShapeLayer *) layer {
CAShapeLayer *layer = [CAShapeLayer layer];
layer.path = [self bubblePath];
if (_fillColor) {
layer.fillColor = _fillColor.CGColor;
if (_strokeColor) {
layer.strokeColor = _strokeColor.CGColor;
}
layer.lineWidth = _lineWidth;
}
return layer;
}
// 设置默认参数
- (void)setDefaultProperty {
_cornerRadius = 8;
_arrowWidth = 30;
_arrowHeight = 12;
_arrowDirection = 1;
_arrowPosition = 0.5;
_arrowRadius = 3;
_lineWidth = 1;
}
But there is a problem. I can see a line over the bubble, because the start point's position is wrong, so i add a method to get start point.
// 获得起点坐标
- (CGPoint)getStartPoint {
NSMutableArray *points = [self keyPoints];
CGPoint currentPoint = [[points objectAtIndex:6] CGPointValue];
// 修改起点的位置,防止最后封闭路径的时候,露出一截
switch (_arrowDirection) {
case ArrowDirectionTop:
{
currentPoint.x = currentPoint.x + _cornerRadius;
}
break;
case ArrowDirectionBottom:
{
currentPoint.x = currentPoint.x - _cornerRadius;
}
break;
case ArrowDirectionLeft:
{
currentPoint.y = currentPoint.y - _cornerRadius;
}
break;
case ArrowDirectionRight:
{
currentPoint.y = currentPoint.y + _cornerRadius;
}
break;
default:
break;
}
return currentPoint;
}
Then change the code CGPoint currentPoint = [[points objectAtIndex:6] CGPointValue]; to CGPoint currentPoint = [self getStartPoint]; at method - (CGPathRef )bubblePath.
Hope you can modify the code at your next version.
It doesn't work, borderColor doesn't work,