File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments