From 9dc106934edaeffaf3c3e64b7c0f74c5fe590cae Mon Sep 17 00:00:00 2001 From: cc Date: Wed, 7 Feb 2018 18:01:48 +0800 Subject: [PATCH] press tips fix --- .../Configuration/OKPlatform.swift | 38 +++++++++++++++++++ .../AccessoryView/OKKLineAccessoryView.swift | 13 +++---- .../Views/MainView/OKKLineMainView.swift | 13 +++---- .../OKKLineSwift/Views/OKKLineDrawView.swift | 2 +- .../Views/VolumeView/OKKLineVolumeView.swift | 15 ++++---- 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/OKKLineMin/OKKLineSwift/Configuration/OKPlatform.swift b/OKKLineMin/OKKLineSwift/Configuration/OKPlatform.swift index c1e0fe0..8b8282a 100644 --- a/OKKLineMin/OKKLineSwift/Configuration/OKPlatform.swift +++ b/OKKLineMin/OKKLineSwift/Configuration/OKPlatform.swift @@ -22,6 +22,7 @@ // SOFTWARE. import SnapKit +import CoreFoundation #if os(iOS) || os(tvOS) @@ -249,4 +250,41 @@ extension OKDescriptable { } } +// fix frame bound compare by CC on 2018/2/7 +extension CGRect { + public static func isSame(_ rect1 : CGRect, _ rect2 : CGRect) -> Bool { + let min : Double = 0.000001 + var delta1 : CGFloat = rect1.origin.x - rect2.origin.x + var delta2 : CGFloat = rect1.origin.y - rect2.origin.y + var delta3 : CGFloat = rect1.size.width - rect2.size.width + var delta4 : CGFloat = rect1.size.height - rect2.size.height + + if delta1 != 0 { + if fabs(Double(delta1)) < min { + delta1 = 0 + } + } + + if delta2 != 0 { + if fabs(Double(delta1)) < min { + delta2 = 0 + } + } + + if delta3 != 0 { + if fabs(Double(delta1)) < min { + delta3 = 0 + } + } + + if delta4 != 0 { + if fabs(Double(delta4)) < min { + delta4 = 0 + } + } + + return (delta1 == 0) && (delta2 == 0) && (delta3 == 0) && (delta4 == 0) + } +} + diff --git a/OKKLineMin/OKKLineSwift/Views/AccessoryView/OKKLineAccessoryView.swift b/OKKLineMin/OKKLineSwift/Views/AccessoryView/OKKLineAccessoryView.swift index d010314..aa1a6ee 100644 --- a/OKKLineMin/OKKLineSwift/Views/AccessoryView/OKKLineAccessoryView.swift +++ b/OKKLineMin/OKKLineSwift/Views/AccessoryView/OKKLineAccessoryView.swift @@ -104,13 +104,12 @@ class OKKLineAccessoryView: OKView { return } -// guard __CGPointEqualToPoint(rect.origin, bounds.origin) && -// __CGSizeEqualToSize(rect.size, bounds.size) -// else { -// -// drawAssistString?.draw(in: rect) -// return -// } + guard CGRect.isSame(rect, bounds) + else { + + drawAssistString?.draw(in: rect) + return + } fetchAssistString(model: accessoryDrawKLineModels.last!) drawAssistString?.draw(in: rect) diff --git a/OKKLineMin/OKKLineSwift/Views/MainView/OKKLineMainView.swift b/OKKLineMin/OKKLineSwift/Views/MainView/OKKLineMainView.swift index 8a487c5..62d8d77 100644 --- a/OKKLineMin/OKKLineSwift/Views/MainView/OKKLineMainView.swift +++ b/OKKLineMin/OKKLineSwift/Views/MainView/OKKLineMainView.swift @@ -110,13 +110,12 @@ class OKKLineMainView: OKView { return } -// guard __CGPointEqualToPoint(rect.origin, bounds.origin) && -// __CGSizeEqualToSize(rect.size, bounds.size) -// else { -// -// drawAssistString?.draw(in: rect) -// return -// } + guard CGRect.isSame(rect, bounds) + else { + + drawAssistString?.draw(in: rect) + return + } // 设置日期背景色 context.setFillColor(configuration.main.assistViewBgColor.cgColor) diff --git a/OKKLineMin/OKKLineSwift/Views/OKKLineDrawView.swift b/OKKLineMin/OKKLineSwift/Views/OKKLineDrawView.swift index af0873e..18d9c3a 100644 --- a/OKKLineMin/OKKLineSwift/Views/OKKLineDrawView.swift +++ b/OKKLineMin/OKKLineSwift/Views/OKKLineDrawView.swift @@ -86,7 +86,7 @@ class OKKLineDrawView: OKView { #endif setupSubviews() - + } required init?(coder aDecoder: NSCoder) { diff --git a/OKKLineMin/OKKLineSwift/Views/VolumeView/OKKLineVolumeView.swift b/OKKLineMin/OKKLineSwift/Views/VolumeView/OKKLineVolumeView.swift index f3ea516..d5f6b36 100644 --- a/OKKLineMin/OKKLineSwift/Views/VolumeView/OKKLineVolumeView.swift +++ b/OKKLineMin/OKKLineSwift/Views/VolumeView/OKKLineVolumeView.swift @@ -93,14 +93,13 @@ class OKKLineVolumeView: OKView { let limitValue = fetchLimitValue() else { return } - -// guard __CGPointEqualToPoint(rect.origin, bounds.origin) && -// __CGSizeEqualToSize(rect.size, bounds.size) -// else { -// -// drawAssistString?.draw(in: rect) -// return -// } + + guard CGRect.isSame(rect, bounds) + else { + + drawAssistString?.draw(in: rect) + return + } // 绘制指标数据 fetchAssistString(model: volumeDrawKLineModels.last!)