Last active
May 22, 2019 12:50
-
-
Save aaronshekey/4e74cbb01c9295539138 to your computer and use it in GitHub Desktop.
Common initialization methods for a custom view in Objective C
This file contains hidden or 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)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