Skip to content

Instantly share code, notes, and snippets.

@aaronshekey
Last active May 22, 2019 12:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronshekey/4e74cbb01c9295539138 to your computer and use it in GitHub Desktop.
Save aaronshekey/4e74cbb01c9295539138 to your computer and use it in GitHub Desktop.
Common initialization methods for a custom view in Objective C
- (void)commonInit
{
CGRect rect = self.frame;
// Top Handle Drawing
UIBezierPath* topHandlePath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect), 8, 8)];
[UIColor.hum_recordingColor setFill];
[topHandlePath fill];
// Bottom Handle Drawing
UIBezierPath* bottomHandlePath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect) + CGRectGetHeight(rect) - 8, 8, 8)];
[UIColor.hum_recordingColor setFill];
[bottomHandlePath fill];
// Connecting Bar Drawing
UIBezierPath* barPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(rect) + 3, CGRectGetMinY(rect) + 7, 2, CGRectGetHeight(rect) - 14)];
[UIColor.hum_recordingColor setFill];
[barPath fill];
}
- (id)init
{
if (self = [super init]) {
[self commonInit];
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self commonInit];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder]) {
[self commonInit];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment