From 894412ec674407db6f5a42416b8e59160da724d5 Mon Sep 17 00:00:00 2001 From: 17chuchu <17chuchu.guy@gmail.com> Date: Fri, 22 Dec 2017 00:09:01 +0700 Subject: [PATCH] Update for Swift 4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I updated your code so that it can be used with Swift 4.0. I don't know a way to apply old version of Swift with new one ,so I just change them a little bit. I personally will be using your lovely code with my UI so we're square. 😁🤘🏻 --- Source/Switch.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Switch.swift b/Source/Switch.swift index cb9db76..16ead5e 100644 --- a/Source/Switch.swift +++ b/Source/Switch.swift @@ -14,15 +14,17 @@ class Switch: UIView { override init(frame: CGRect) { super.init(frame: frame) - self.backgroundColor = UIColor.clearColor() + self.backgroundColor = UIColor.clear } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - override func drawRect(rect: CGRect) { - let rectanglePath = UIBezierPath(roundedRect: CGRectMake(0.0, 0.0, rect.size.width, rect.size.height), cornerRadius: rect.size.width / 2.0) + override func draw(_ rect: CGRect) { + + + let rectanglePath = UIBezierPath(roundedRect: CGRect(x: 0.0, y: 0.0, width: rect.size.width, height: rect.size.height), cornerRadius: CGFloat(rect.size.width / 2.0)) self.switchColor.setFill() rectanglePath.fill() }