Created
December 31, 2014 15:08
-
-
Save GnuRant/af2dfbd0ec426019efe6 to your computer and use it in GitHub Desktop.
Draw 1px border in a UIView
This file contains 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
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