Skip to content

Commit

Permalink
press tips fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ccworld1000 committed Feb 7, 2018
1 parent 77940d8 commit 9dc1069
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
38 changes: 38 additions & 0 deletions OKKLineMin/OKKLineSwift/Configuration/OKPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// SOFTWARE.

import SnapKit
import CoreFoundation

#if os(iOS) || os(tvOS)

Expand Down Expand Up @@ -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)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions OKKLineMin/OKKLineSwift/Views/MainView/OKKLineMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion OKKLineMin/OKKLineSwift/Views/OKKLineDrawView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class OKKLineDrawView: OKView {
#endif

setupSubviews()

}

required init?(coder aDecoder: NSCoder) {
Expand Down
15 changes: 7 additions & 8 deletions OKKLineMin/OKKLineSwift/Views/VolumeView/OKKLineVolumeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down

0 comments on commit 9dc1069

Please sign in to comment.