Skip to content

Commit 580aa79

Browse files
author
Eric Rolf
committed
Updated to support images for the center of the progress view.
1 parent 4397973 commit 580aa79

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ProgressView/CircleProgressView.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ import UIKit
6060
@IBInspectable public var centerFillColor: UIColor = UIColor.whiteColor() {
6161
didSet { setNeedsDisplay() }
6262
}
63+
64+
@IBInspectable public var centerImage: UIImage? {
65+
didSet { setNeedsDisplay() }
66+
}
6367

6468
@IBInspectable public var contentView: UIView {
6569
return self.constants.contentView
@@ -130,8 +134,16 @@ import UIKit
130134
centerFillColor.setFill()
131135
centerPath.fill()
132136

133-
let layer = CAShapeLayer()
134-
layer.path = centerPath.CGPath
135-
contentView.layer.mask = layer
137+
if let centerImage = centerImage {
138+
CGContextSaveGState(context)
139+
centerPath.addClip()
140+
centerImage.drawInRect(rect)
141+
CGContextRestoreGState(context)
142+
} else {
143+
let layer = CAShapeLayer()
144+
layer.path = centerPath.CGPath
145+
contentView.layer.mask = layer
146+
}
147+
136148
}
137149
}

0 commit comments

Comments
 (0)