Created
October 10, 2013 01:54
-
-
Save ferbass/6911840 to your computer and use it in GitHub Desktop.
create a dashed border using CoreGraphics, in your custom view puts thats code on drawRect method.
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
- (void)drawRect:(CGRect)rect | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetStrokeColorWithColor(context, [[UIColor grayColor] CGColor]); | |
CGFloat dashes[] = {1,1}; | |
CGContextSetLineDash(context, 0.0, dashes, 2); | |
CGContextSetLineWidth(context, 1.0); | |
CGContextMoveToPoint(context, CGRectGetMinX(rect), CGRectGetMaxY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMaxY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMinY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMinX(rect), CGRectGetMaxY(rect)); | |
CGContextSetShouldAntialias(context, NO); | |
CGContextStrokePath(context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment