Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created May 12, 2012
Embed
What would you like to do?
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