diff --git a/FSPagerViewExamples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/FSPagerViewExamples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/FSPagerViewExamples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Sources/FSPageControl.swift b/Sources/FSPageControl.swift index e3bd745..0e5de62 100644 --- a/Sources/FSPageControl.swift +++ b/Sources/FSPageControl.swift @@ -245,10 +245,25 @@ open class FSPageControl: UIControl { let index = self.indicatorLayers.firstIndex(of: layer) let state: UIControl.State = index == self.currentPage ? .selected : .normal if let image = self.images[state] { + + let imageLayer = CALayer() + imageLayer.backgroundColor = UIColor.clear.cgColor + imageLayer.frame = CGRect(origin: CGPoint.zero, size: image.size) + imageLayer.contentsGravity = .resize + imageLayer.contents = image.cgImage + imageLayer.setNeedsLayout() + layer.strokeColor = nil - layer.fillColor = nil + layer.fillColor = UIColor(patternImage: image).cgColor layer.path = nil - layer.contents = image.cgImage + + for s in 0..<(layer.sublayers?.count ?? 0) { + if ((layer.sublayers?[s].isEqual(imageLayer)) != nil) { + layer.sublayers?[s].removeFromSuperlayer() + } + } + layer.addSublayer(imageLayer) + } else { layer.contents = nil let strokeColor = self.strokeColors[state]