Created
August 4, 2017 11:02
-
-
Save tularovbeslan/1a7bc23bc9dea99eda0a5d81be819957 to your computer and use it in GitHub Desktop.
UIPageControl dot border
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
class func outlinedEllipse(size: CGSize, color: UIColor, lineWidth: CGFloat = 1.0) -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(size, false, 0.0) | |
guard let context = UIGraphicsGetCurrentContext() else { | |
return nil | |
} | |
context.setStrokeColor(color.cgColor) | |
context.setLineWidth(lineWidth) | |
let rect = CGRect(origin: .zero, size: size).insetBy(dx: lineWidth * 0.5, dy: lineWidth * 0.5) | |
context.addEllipse(in: rect) | |
context.strokePath() | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} | |
} | |
//USE | |
let image = UIImage.outlinedEllipse(size: CGSize(width: 7.0, height: 7.0), color: .lightGray) | |
self.pageControl.pageIndicatorTintColor = UIColor.init(patternImage: image!) | |
self.pageControl.currentPageIndicatorTintColor = .lightGray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment