diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 24c0e52..e59f2e2 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -7,7 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 1C1E3C571B34CFE2005F495B /* GaugeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C1E3C561B34CFE2005F495B /* GaugeKit.framework */; }; + 1C4B1A471B37F491008720C6 /* GaugeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C4B1A461B37F491008720C6 /* GaugeKit.framework */; }; + 1C4B1A481B37F491008720C6 /* GaugeKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1C4B1A461B37F491008720C6 /* GaugeKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1C9404FB1B31D057001BF122 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C9404FA1B31D057001BF122 /* AppDelegate.swift */; }; 1C9405001B31D057001BF122 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1C9404FE1B31D057001BF122 /* Main.storyboard */; }; 1C9405021B31D057001BF122 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1C9405011B31D057001BF122 /* Images.xcassets */; }; @@ -27,8 +28,23 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 1C4B1A491B37F492008720C6 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 1C4B1A481B37F491008720C6 /* GaugeKit.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 1C1E3C561B34CFE2005F495B /* GaugeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GaugeKit.framework; path = "../build/Debug-iphoneos/GaugeKit.framework"; sourceTree = ""; }; + 1C4B1A461B37F491008720C6 /* GaugeKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = GaugeKit.framework; path = "/Users/petrkorolev/Library/Developer/Xcode/DerivedData/GaugeKit-evarryfseqjhwbcgaxucqvnmcesq/Build/Products/Debug-iphoneos/GaugeKit.framework"; sourceTree = ""; }; 1C9404F51B31D057001BF122 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1C9404F91B31D057001BF122 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1C9404FA1B31D057001BF122 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -47,7 +63,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1C1E3C571B34CFE2005F495B /* GaugeKit.framework in Frameworks */, + 1C4B1A471B37F491008720C6 /* GaugeKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -64,6 +80,7 @@ 1C9404EC1B31D057001BF122 = { isa = PBXGroup; children = ( + 1C4B1A461B37F491008720C6 /* GaugeKit.framework */, 1C1E3C561B34CFE2005F495B /* GaugeKit.framework */, 1C9404F71B31D057001BF122 /* Example */, 1C94050D1B31D057001BF122 /* ExampleTests */, @@ -129,6 +146,7 @@ 1C9404F11B31D057001BF122 /* Sources */, 1C9404F21B31D057001BF122 /* Frameworks */, 1C9404F31B31D057001BF122 /* Resources */, + 1C4B1A491B37F492008720C6 /* Embed Frameworks */, ); buildRules = ( ); @@ -163,7 +181,8 @@ 1C9404ED1B31D057001BF122 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = "Petr Korolev"; TargetAttributes = { 1C9404F41B31D057001BF122 = { @@ -284,6 +303,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -354,6 +374,7 @@ INFOPLIST_FILE = Example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "SW.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -366,6 +387,7 @@ INFOPLIST_FILE = Example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "SW.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -381,6 +403,7 @@ ); INFOPLIST_FILE = ExampleTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "SW.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; @@ -393,6 +416,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = ExampleTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "SW.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard index 641a2cf..da8bc80 100644 --- a/Example/Example/Base.lproj/Main.storyboard +++ b/Example/Example/Base.lproj/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -20,7 +20,7 @@ - + @@ -34,28 +34,28 @@ - + - + - + @@ -70,9 +70,8 @@ - - + @@ -92,7 +91,7 @@ - + @@ -105,7 +104,7 @@ - + @@ -136,7 +135,7 @@ - + @@ -153,10 +152,16 @@ - + + + + + + + @@ -168,13 +173,13 @@ - + @@ -187,7 +192,6 @@ - @@ -198,6 +202,7 @@ + @@ -280,6 +285,7 @@ + @@ -296,7 +302,7 @@ - + @@ -304,6 +310,7 @@ + @@ -400,7 +407,7 @@ - + diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist index 7647a91..40c6215 100644 --- a/Example/Example/Info.plist +++ b/Example/Example/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - SW.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example/ExampleTests/Info.plist b/Example/ExampleTests/Info.plist index d6f8426..ba72822 100644 --- a/Example/ExampleTests/Info.plist +++ b/Example/ExampleTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - SW.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/GaugeKit.xcodeproj/project.pbxproj b/GaugeKit.xcodeproj/project.pbxproj index f3d3ab2..158a4e3 100644 --- a/GaugeKit.xcodeproj/project.pbxproj +++ b/GaugeKit.xcodeproj/project.pbxproj @@ -170,6 +170,7 @@ 1C9404C71B31CF85001BF122 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0630; ORGANIZATIONNAME = "Petr Korolev"; TargetAttributes = { diff --git a/GaugeKit.xcworkspace/xcshareddata/GaugeKit.xcscmblueprint b/GaugeKit.xcworkspace/xcshareddata/GaugeKit.xcscmblueprint new file mode 100644 index 0000000..48a9a1e --- /dev/null +++ b/GaugeKit.xcworkspace/xcshareddata/GaugeKit.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "D316725E3745C2E3F6B4E61E23722FBEC4818660", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "D316725E3745C2E3F6B4E61E23722FBEC4818660" : 0, + "3715728EE139841130E5A94A8487F1BF54266A48" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "4AB4A397-B2EE-4F60-A406-49F77742D5FC", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "D316725E3745C2E3F6B4E61E23722FBEC4818660" : "GaugeKit", + "3715728EE139841130E5A94A8487F1BF54266A48" : "SWGauge" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "GaugeKit", + "DVTSourceControlWorkspaceBlueprintVersion" : 203, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "GaugeKit.xcworkspace", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:skywinder\/SWGauge.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3715728EE139841130E5A94A8487F1BF54266A48" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:skywinder\/GaugeKit.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "D316725E3745C2E3F6B4E61E23722FBEC4818660" + } + ] +} \ No newline at end of file diff --git a/GaugeKit/Gauge.swift b/GaugeKit/Gauge.swift index f1d1e39..5d5b54f 100644 --- a/GaugeKit/Gauge.swift +++ b/GaugeKit/Gauge.swift @@ -38,7 +38,7 @@ public class Gauge: UIView { if let endColor = endColor { return endColor } else { - return startColor + return UIColor.redColor() } } set { @@ -76,7 +76,7 @@ public class Gauge: UIView { } } } - @IBInspectable var bgAlpha: CGFloat = 0.4 { + @IBInspectable var bgAlpha: CGFloat = 0.2 { didSet { updateLayerProperties() } @@ -86,21 +86,21 @@ public class Gauge: UIView { updateLayerProperties() } } - @IBInspectable var customColors: Bool = true { + @IBInspectable var colorsArray: Bool = false { + didSet { + updateLayerProperties() + } + } + @IBInspectable var shadowRadius: CGFloat = 0 { + didSet { + updateLayerProperties() + } + } + @IBInspectable var shadowOpacity: Float = 0.5 { didSet { updateLayerProperties() } } -// @IBInspectable var ringShadowRadius: CGFloat = 0 { -// didSet { -// updateLayerProperties() -// } -// } -// @IBInspectable var ringShadowOpacity: Float = 0 { -// didSet { -// updateLayerProperties() -// } -// } @IBInspectable public var reverse: Bool = false { didSet { @@ -170,7 +170,7 @@ public class Gauge: UIView { var strokeColor = UIColor.lightGrayColor() //TODO: replace pre-defined colors with array of user-defined colors //TODO: and split them proportionally in whole sector - if !customColors { + if colorsArray { switch (rate / 10) { case let r where r >= 0.75: strokeColor = UIColor(hue: diff --git a/GaugeKit/GaugeCircle.swift b/GaugeKit/GaugeCircle.swift index e4d6be4..214706c 100644 --- a/GaugeKit/GaugeCircle.swift +++ b/GaugeKit/GaugeCircle.swift @@ -22,13 +22,13 @@ public class GaugeCircle: Gauge { let gaugeLayer = CAShapeLayer() if bgLayer == nil { - bgLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 1, strokeColor: _bgStartColor, fillColor: UIColor.clearColor(), shadowRadius: 0, shadowOpacity: 0, shadowOffsset: CGSizeZero, bounds: bounds) + bgLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 1, strokeColor: _bgStartColor, fillColor: UIColor.clearColor(), shadowRadius: shadowRadius, shadowOpacity: shadowOpacity, shadowOffsset: CGSizeZero, bounds: bounds) bgLayer.frame = layer.bounds gaugeLayer.addSublayer(bgLayer) } if ringLayer == nil { - ringLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 1, strokeColor: UIColor.clearColor(), fillColor: UIColor.clearColor(), shadowRadius: 0, shadowOpacity: 0, shadowOffsset: CGSizeZero, bounds: bounds) + ringLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 1, strokeColor: UIColor.clearColor(), fillColor: UIColor.clearColor(), shadowRadius: shadowRadius, shadowOpacity: shadowOpacity, shadowOffsset: CGSizeZero, bounds: bounds) ringLayer.frame = layer.bounds gaugeLayer.addSublayer(ringLayer) diff --git a/GaugeKit/GaugeHalf.swift b/GaugeKit/GaugeHalf.swift index 2aa178f..57c225a 100644 --- a/GaugeKit/GaugeHalf.swift +++ b/GaugeKit/GaugeHalf.swift @@ -12,7 +12,6 @@ import QuartzCore @IBDesignable public class GaugeHalf: Gauge { - @IBInspectable var right: Bool = false { didSet { self.type = right ? GaugeType.Right : GaugeType.Left @@ -20,6 +19,19 @@ public class GaugeHalf: Gauge { } } + + required public init(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + self.type = right ? GaugeType.Right : GaugeType.Left + updateLayerProperties() + } + + public override init(frame: CGRect) { + super.init(frame: frame) + self.type = right ? GaugeType.Right : GaugeType.Left + updateLayerProperties() + } + override public func layoutSubviews() { super.layoutSubviews() @@ -27,7 +39,7 @@ public class GaugeHalf: Gauge { } override func getGauge(rotateAngle: Double = 0) -> CALayer { - var gaugeLayer = getHalfGauge(rotateAngle: rotateAngle) + let gaugeLayer = getHalfGauge(rotateAngle: rotateAngle) return gaugeLayer } @@ -36,11 +48,11 @@ public class GaugeHalf: Gauge { let gaugeLayer = CAShapeLayer() // let rotatedBounds = CGRectMake(10, 10, bounds.height, bounds.width) - var newBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.height, bounds.width * 2 - lineWidth) + let newBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.height, bounds.width * 2 - lineWidth) // var newBounds = bounds if bgLayer == nil { bgLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 0.5, strokeColor: _bgStartColor, - fillColor: UIColor.clearColor(), shadowRadius: 0, shadowOpacity: 0, shadowOffsset: CGSizeZero, bounds: newBounds, rotateAngle: M_PI_2, isCircle: isCircle) + fillColor: UIColor.clearColor(), shadowRadius: shadowRadius, shadowOpacity: shadowOpacity, shadowOffsset: CGSizeZero, bounds: newBounds, rotateAngle: M_PI_2, isCircle: isCircle) bgLayer.frame = layer.bounds bgLayer.position = CGPointMake(bgLayer.position.x + bounds.width - lineWidth, bgLayer.position.y) } @@ -63,7 +75,7 @@ public class GaugeHalf: Gauge { if ringLayer == nil { ringLayer = CAShapeLayer.getOval(lineWidth, path: nil, strokeStart: 0, strokeEnd: 0.5, strokeColor: startColor, - fillColor: UIColor.clearColor(), shadowRadius: 0, shadowOpacity: 0, shadowOffsset: CGSizeZero, bounds: newBounds, rotateAngle: M_PI_2, isCircle: isCircle) + fillColor: UIColor.clearColor(), shadowRadius: shadowRadius, shadowOpacity: shadowOpacity, shadowOffsset: CGSizeZero, bounds: newBounds, rotateAngle: M_PI_2, isCircle: isCircle) ringLayer.frame = layer.bounds ringLayer.position = CGPointMake(ringLayer.position.x + bounds.width - lineWidth, ringLayer.position.y) } diff --git a/Images/gauge.gif b/Images/gauge.gif index affb8f6..0a2a5fd 100644 Binary files a/Images/gauge.gif and b/Images/gauge.gif differ diff --git a/README.md b/README.md index 9dd9397..805c718 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ GaugeKit is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: ```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' +use_frameworks! + pod "GaugeKit" ```