Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created May 12, 2012 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C4Code/2667489 to your computer and use it in GitHub Desktop.
Save C4Code/2667489 to your computer and use it in GitHub Desktop.
how to structure the init method of a custom shape class
//
// C4WorkSpace.m
// customShapeInit
//
// Created by Travis Kirton on 12-04-30.
// Copyright (c) 2012 POSTFL. All rights reserved.
//
#import "C4WorkSpace.h"
#import "MyShape.h"
@implementation C4WorkSpace
-(void)setup {
MyShape *ms = [MyShape new];
[ms ellipse:CGRectMake(100, 100, 100, 100)];
[self.canvas addShape:ms];
}
@end
//
// MyShape.h
// customShapeInit
//
// Created by Travis Kirton on 12-04-30.
// Copyright (c) 2012 POSTFL. All rights reserved.
//
#import "C4Shape.h"
@interface MyShape : C4Shape
@end
//
// MyShape.m
// customShapeInit
//
// Created by Travis Kirton on 12-04-30.
// Copyright (c) 2012 POSTFL. All rights reserved.
//
#import "MyShape.h"
@implementation MyShape
-(id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self != nil) {
self.animationDuration = 0.0f;
self.fillColor = [UIColor purpleColor];
self.strokeColor = [UIColor greenColor];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment