Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Limon-O-O committed Feb 28, 2017
1 parent 2f074aa commit 753ca3e
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions Sources/MonkeyKing.swift
Expand Up @@ -1573,31 +1573,6 @@ extension MonkeyKing {
}
}


class CloseButton: UIButton {

override func draw(_ rect: CGRect) {

let circleWidth: CGFloat = 28.0
let circlePathX = (rect.width - circleWidth) / 2.0
let circlePathY = (rect.height - circleWidth) / 2.0
let circlePathRect = CGRect(x: circlePathX, y: circlePathY, width: circleWidth, height: circleWidth)
let circlePath = UIBezierPath(ovalIn: circlePathRect)
UIColor(white: 0.8, alpha: 1.0).setFill()
circlePath.fill()

let xPath = UIBezierPath()
xPath.lineWidth = 2.0
let offset: CGFloat = (bounds.width - circleWidth) / 2.0
xPath.move(to: CGPoint(x: offset + circleWidth / 4.0, y: offset + circleWidth / 4.0))
xPath.addLine(to: CGPoint(x: offset + 3.0 * circleWidth / 4.0, y: offset + 3.0 * circleWidth / 4.0))
xPath.move(to: CGPoint(x: offset + circleWidth / 4.0, y: offset + 3.0 * circleWidth / 4.0))
xPath.addLine(to: CGPoint(x: offset + 3.0 * circleWidth / 4.0, y: offset + circleWidth / 4.0))
UIColor.white.setStroke()
xPath.stroke()
}
}

// MARK: Private Extensions

private extension Set {
Expand Down Expand Up @@ -1850,3 +1825,26 @@ private extension UIImage {
}
}

class CloseButton: UIButton {

override func draw(_ rect: CGRect) {

let circleWidth: CGFloat = 28.0
let circlePathX = (rect.width - circleWidth) / 2.0
let circlePathY = (rect.height - circleWidth) / 2.0
let circlePathRect = CGRect(x: circlePathX, y: circlePathY, width: circleWidth, height: circleWidth)
let circlePath = UIBezierPath(ovalIn: circlePathRect)
UIColor(white: 0.8, alpha: 1.0).setFill()
circlePath.fill()

let xPath = UIBezierPath()
xPath.lineWidth = 2.0
let offset: CGFloat = (bounds.width - circleWidth) / 2.0
xPath.move(to: CGPoint(x: offset + circleWidth / 4.0, y: offset + circleWidth / 4.0))
xPath.addLine(to: CGPoint(x: offset + 3.0 * circleWidth / 4.0, y: offset + 3.0 * circleWidth / 4.0))
xPath.move(to: CGPoint(x: offset + circleWidth / 4.0, y: offset + 3.0 * circleWidth / 4.0))
xPath.addLine(to: CGPoint(x: offset + 3.0 * circleWidth / 4.0, y: offset + circleWidth / 4.0))
UIColor.white.setStroke()
xPath.stroke()
}
}

0 comments on commit 753ca3e

Please sign in to comment.