From a3938cd80f663eb4d8d857962de088b1ad42135a Mon Sep 17 00:00:00 2001 From: zzb <350991881@qq.com> Date: Thu, 26 Nov 2020 14:06:20 +0800 Subject: [PATCH 1/3] modify offsetCoefficient DateType to CGFloat in method" - (CGFloat)offsetCoefficient" --- CRRulerControl/Classes/CRRulerControl.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRRulerControl/Classes/CRRulerControl.m b/CRRulerControl/Classes/CRRulerControl.m index 01eb7a4..990f156 100644 --- a/CRRulerControl/Classes/CRRulerControl.m +++ b/CRRulerControl/Classes/CRRulerControl.m @@ -159,7 +159,7 @@ - (CGFloat)valueForContentOffset:(CGPoint)contentOffset { } - (CGFloat)offsetCoefficient { - NSInteger distance = self.rulerRange.length; + CGFloat distance = self.rulerRange.length; return (self.scrollView.contentSize.width - kSideOffset * 2) / distance; } @@ -469,4 +469,4 @@ - (CGPoint)offsetForMarkType:(CRRulerMarkType)markType { return CGPointZero; } -@end \ No newline at end of file +@end From 81d5215e52b9b56832e1f298e263b2c6e486f7b5 Mon Sep 17 00:00:00 2001 From: zzb <350991881@qq.com> Date: Wed, 9 Dec 2020 18:23:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E4=BA=86tintColorDidChan?= =?UTF-8?q?ge=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRRulerControl/Classes/CRRulerControl.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRRulerControl/Classes/CRRulerControl.m b/CRRulerControl/Classes/CRRulerControl.m index 990f156..eaf9928 100644 --- a/CRRulerControl/Classes/CRRulerControl.m +++ b/CRRulerControl/Classes/CRRulerControl.m @@ -166,9 +166,9 @@ - (CGFloat)offsetCoefficient { #pragma mark - User interaction - (void)tintColorDidChange { - [self setColor:self.tintColor forMarkType:CRRulerMarkTypeAll]; - [self setTextColor:self.tintColor forMarkType:CRRulerMarkTypeMiddle | CRRulerMarkTypeMajor]; - self.pointerImageView.backgroundColor = self.tintColor; +// [self setColor:self.tintColor forMarkType:CRRulerMarkTypeAll]; +// [self setTextColor:self.tintColor forMarkType:CRRulerMarkTypeMiddle | CRRulerMarkTypeMajor]; +// self.pointerImageView.backgroundColor = self.tintColor; } #pragma mark - Setters From 440e2a2ecc00ef8e4eb9156ad015a66e56a75f70 Mon Sep 17 00:00:00 2001 From: zzb <350991881@qq.com> Date: Wed, 16 Dec 2020 11:25:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86isSetValued?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E6=94=B9=E4=BA=86scrollViewDidScroll?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C=E6=BB=9A=E5=8A=A8=E5=92=8C?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=88=86=E5=BC=80=EF=BC=8C=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=BA=86=E8=AE=A1=E7=AE=97=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRRulerControl/.DS_Store | Bin 0 -> 6148 bytes CRRulerControl/Classes/CRRulerControl.m | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 CRRulerControl/.DS_Store diff --git a/CRRulerControl/.DS_Store b/CRRulerControl/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0306d46d74caf3a66f73e7886dc125c38e3c99eb GIT binary patch literal 6148 zcmeHK%}&BV5Z(op1!Lr3BFA35aezSJWYQEocr&TdgBoZ1*g4`2@a> zGrJ23q6aU=keO!oo1LHC?AK99Fh+K{lGmph? z8c*F|BbyxmkpX;nW!7f_b65<|>itD7MBd$L;Kxa``N0dt(#~#Kh^naWS8we}l-h}t z%wx-$U1RUuNhYqgFQO<|*^YbZd+D%t*pI@*@k4JWi~X?&DK}SsIF3>)nup_9j$^BU z5EW4w*6LZ-Zgv_*r`uaJjI7sdg5B;e78P-H+&VcM-9J8M&x@B=#Vv==P|AVECA@+0 zWtk85EDWOX4kF8{Wi}x(KnxHATh4&q_Qc+nualNX3=jjqX8`vH0~FEJm@AZ92Q>Km zi18943fOp;Kr}R(8gqpZ0pY3?P?d6h#o($O{D#gmHRcLcIpcC>7)Q^{^$mr~*}-qf zbjD4E)Di>4z&Zm()ve+AfBN(Nf4zu$!~ij{RSfXbz#dqzBz?ASEDq0F19Sw6f_b^Z lRS6jKD27}-itC_Kz;B=dXll$Af(L|t1SAdA5Ceb8z$X-IQmOy| literal 0 HcmV?d00001 diff --git a/CRRulerControl/Classes/CRRulerControl.m b/CRRulerControl/Classes/CRRulerControl.m index eaf9928..7376ff9 100644 --- a/CRRulerControl/Classes/CRRulerControl.m +++ b/CRRulerControl/Classes/CRRulerControl.m @@ -21,7 +21,7 @@ @interface CRRulerControl () @property (nonatomic) CRRulerLayer *rulerLayer; @property (nonatomic, readwrite) UIScrollView *scrollView; @property (nonatomic, readwrite) UIImageView *pointerImageView; - +@property (nonatomic, assign) BOOL isSetValued; @end @implementation CRRulerControl @@ -129,7 +129,12 @@ - (void)setupRulerLayer { - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat oldValue = _value; - _value = [self valueForContentOffset:scrollView.contentOffset]; + if (_isSetValued) { + _value = [self valueForContentOffset:[self contentOffsetForValue:_value]]; + _isSetValued = false; + }else{ + _value = [self valueForContentOffset:scrollView.contentOffset]; + } if (oldValue != _value) { [self sendActionsForControlEvents:UIControlEventValueChanged]; } @@ -216,6 +221,7 @@ - (void)setValue:(CGFloat)value { - (void)setValue:(CGFloat)value animated:(BOOL)animated { _value = value; + _isSetValued = true; [self.scrollView setContentOffset:[self contentOffsetForValue:value] animated:animated]; }