diff --git a/StepIndicator/AnnularLayer.swift b/StepIndicator/AnnularLayer.swift index f916681..6953e27 100644 --- a/StepIndicator/AnnularLayer.swift +++ b/StepIndicator/AnnularLayer.swift @@ -13,6 +13,7 @@ class AnnularLayer: CAShapeLayer { private let fullCircleLayer = CAShapeLayer() private let centerCircleLayer = CAShapeLayer() private let flagLayer = CALayer() + private let maskLayer = CALayer() private let annularPath = UIBezierPath() lazy private var centerTextLayer = CATextLayer() @@ -23,6 +24,7 @@ class AnnularLayer: CAShapeLayer { // MARK: - Properties var tintColor:UIColor? + var flagTintColor:UIColor? var displayNumber = false var step:Int = 0 var annularDefaultColor: UIColor? @@ -72,7 +74,8 @@ class AnnularLayer: CAShapeLayer { } self.flagLayer.contents = AnnularLayer.flagCGImage - self.fullCircleLayer.addSublayer(self.flagLayer) + self.maskLayer.mask = self.flagLayer + self.fullCircleLayer.addSublayer(self.maskLayer) } required init?(coder aDecoder: NSCoder) { @@ -207,7 +210,8 @@ class AnnularLayer: CAShapeLayer { let flagLayerWidth = self.fullCircleLayer.bounds.width * 0.8 let flagLayerHeight = self.fullCircleLayer.bounds.height * 0.8 self.flagLayer.frame = CGRect(x: self.fullCircleLayer.bounds.width * 0.2 / 2.0, y: self.fullCircleLayer.bounds.height * 0.2 / 2.0, width:flagLayerWidth, height:flagLayerHeight) - + self.maskLayer.frame = self.flagLayer.bounds + self.maskLayer.backgroundColor = self.flagTintColor?.cgColor self.animateFullCircle() } diff --git a/StepIndicator/StepIndicatorView.swift b/StepIndicator/StepIndicatorView.swift index 76d1f5e..945f3a0 100644 --- a/StepIndicator/StepIndicatorView.swift +++ b/StepIndicator/StepIndicatorView.swift @@ -110,6 +110,12 @@ public class StepIndicatorView: UIView { } } + @IBInspectable public var flagTintColor:UIColor = .white { + didSet { + self.updateSubLayers() + } + } + public var direction:StepIndicatorViewDirection = .leftToRight { didSet{ self.updateSubLayers() @@ -225,6 +231,7 @@ public class StepIndicatorView: UIView { private func applyAnnularStyle(annularLayer:AnnularLayer) { annularLayer.annularDefaultColor = self.circleColor annularLayer.tintColor = self.circleTintColor + annularLayer.flagTintColor = self.flagTintColor annularLayer.lineWidth = self.circleStrokeWidth annularLayer.displayNumber = self.displayNumbers annularLayer.showFlag = self.showFlag diff --git a/StepIndicatorDemo.xcodeproj/project.xcworkspace/xcuserdata/babel.xcuserdatad/UserInterfaceState.xcuserstate b/StepIndicatorDemo.xcodeproj/project.xcworkspace/xcuserdata/babel.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..486d52f Binary files /dev/null and b/StepIndicatorDemo.xcodeproj/project.xcworkspace/xcuserdata/babel.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..3267807 --- /dev/null +++ b/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcschemes/xcschememanagement.plist b/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..9ad67bb --- /dev/null +++ b/StepIndicatorDemo.xcodeproj/xcuserdata/babel.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + StepIndicatorDemo.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/StepIndicatorDemo/Base.lproj/Main.storyboard b/StepIndicatorDemo/Base.lproj/Main.storyboard index e9128ec..12da0ea 100644 --- a/StepIndicatorDemo/Base.lproj/Main.storyboard +++ b/StepIndicatorDemo/Base.lproj/Main.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -14,7 +12,7 @@ - + @@ -38,7 +36,7 @@ - + @@ -68,7 +66,7 @@ - + @@ -107,7 +105,7 @@ - + @@ -126,7 +124,7 @@ - + @@ -145,25 +143,25 @@ - +