Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created March 22, 2013 15:50
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/5222356 to your computer and use it in GitHub Desktop.
Save C4Code/5222356 to your computer and use it in GitHub Desktop.
Simple Button Example
#import "C4WorkSpace.h"
@implementation C4WorkSpace {
C4Button *b;
BOOL shiftDir;
}
-(void)setup {
b = [C4Button buttonWithType:ROUNDEDRECT];
b.center = self.canvas.center;
[self.canvas addSubview:b];
[b runMethod:@"shift" target:self forEvent:TOUCHUPINSIDE];
}
-(void)shift {
CGPoint center = b.center;
if(shiftDir == NO) center.x += [C4Math randomInt:100]/25.0f;
else center.y += [C4Math randomInt:100]/25.0f;
b.center = center;
shiftDir = !shiftDir;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment