From 621f482d8dcac1a0cace1fd321d7c1a6a741d0c6 Mon Sep 17 00:00:00 2001 From: weiqingjiang Date: Fri, 10 Dec 2021 13:48:42 +0800 Subject: [PATCH] fix count - 1 == 0 , layer use crash --- YYKline/Painter/YYVerticalText/YYVerticalTextPainter.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/YYKline/Painter/YYVerticalText/YYVerticalTextPainter.m b/YYKline/Painter/YYVerticalText/YYVerticalTextPainter.m index 65ff6c9..5540fd3 100644 --- a/YYKline/Painter/YYVerticalText/YYVerticalTextPainter.m +++ b/YYKline/Painter/YYVerticalText/YYVerticalTextPainter.m @@ -23,6 +23,10 @@ + (void)drawToLayer:(CALayer *)layer area:(CGRect)area minMax: (YYMinMaxModel *) // 数字40只是一个magic数字,没啥特殊意义 NSInteger count = maxH/40; count++; + if (count == 1) { + + return; + } CGFloat lineH = [UIFont systemFontOfSize:12.f].lineHeight; CGFloat textGap = (maxH - lineH)/(count-1); CGFloat decimalGap = minMaxModel.distance / (count-1);