diff --git a/Sources/ViewChaos.swift b/Sources/ViewChaos.swift index a79fa74..e074cb0 100644 --- a/Sources/ViewChaos.swift +++ b/Sources/ViewChaos.swift @@ -11,7 +11,7 @@ enum ChaosFeature:Int{ case none=0,zoom,border,alpha,mark,Log } -public protocol SelfAware:class { +public protocol SelfAware:AnyObject { static func awake(defaultActive:Bool) } diff --git a/Sources/ZoomView.swift b/Sources/ZoomView.swift index 03a05ba..3f79da2 100644 --- a/Sources/ZoomView.swift +++ b/Sources/ZoomView.swift @@ -63,11 +63,11 @@ class ZoomView: UIWindow { didSet{ if let point = pointToZoom{ self.center = CGPoint(x: point.x, y: point.y) - let offset:Int = Int(4 * ((imgSize.width * round(point.y*2)) + round(point.x*2))) - let a = UInt64(imgCaptureData![offset]) - let r = UInt64(imgCaptureData![offset + 1]) - let g = UInt64(imgCaptureData![offset + 2]) - let b = UInt64(imgCaptureData![offset + 3]) + let offset = 4 * ((imgSize.width * round(point.y*2)) + round(point.x*2)) + let a = UInt64(imgCaptureData![Int(offset)]) + let r = UInt64(imgCaptureData![Int(offset) + 1]) + let g = UInt64(imgCaptureData![Int(offset) + 2]) + let b = UInt64(imgCaptureData![Int(offset) + 3]) currentColor = UIColor(red:CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: CGFloat(a) / 255.0) print("point:\(point) the color is :\(String(describing: currentColor?.format("swift")))") //大功基本告成,我再加个Lable来显示就行 diff --git a/ViewChaosDemo/ViewChaosDemo/Main.storyboard b/ViewChaosDemo/ViewChaosDemo/Main.storyboard index 6c12f02..4cff478 100644 --- a/ViewChaosDemo/ViewChaosDemo/Main.storyboard +++ b/ViewChaosDemo/ViewChaosDemo/Main.storyboard @@ -1,12 +1,9 @@ - - - - + + - - + @@ -23,10 +20,10 @@ - + - -