Skip to content

Instantly share code, notes, and snippets.

@GnuRant
Created December 31, 2014 15:08
Show Gist options
  • Save GnuRant/af2dfbd0ec426019efe6 to your computer and use it in GitHub Desktop.
Save GnuRant/af2dfbd0ec426019efe6 to your computer and use it in GitHub Desktop.
Draw 1px border in a UIView
override func drawRect(rect: CGRect) {
var ctx = UIGraphicsGetCurrentContext()
var path = UIBezierPath(rect: rect)
var innerBorder = rect
innerBorder.origin.x += 1.0
innerBorder.origin.y += 1.0
innerBorder.size.width -= 2.0
innerBorder.size.height -= 2.0
var innerBorderPath = UIBezierPath(rect: innerBorder)
path.appendPath(innerBorderPath)
let borderColor = CustomColor().grey
borderColor.setStroke()
path.stroke()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment