Last active
December 18, 2015 01:29
-
-
Save xr1337/5704301 to your computer and use it in GitHub Desktop.
Adding a touch Path
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
@implementation RoundTouchButton{ | |
CGPathRef touchPath; | |
} | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
// Initialization code | |
touchPath = CGPathCreateWithEllipseInRect(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), NULL); | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
CGPathRelease(touchPath); | |
} | |
- (void)drawRect:(CGRect)rect | |
{ | |
// Drawing code | |
// debug | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(ctx, [UIColor purpleColor].CGColor); | |
CGContextSetLineWidth(ctx, 1); | |
CGContextAddPath(ctx, touchPath); | |
CGContextDrawPath(ctx, kCGPathFillStroke); | |
UIGraphicsEndImageContext(); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment