Created
March 22, 2013 15:50
-
-
Save C4Code/5222356 to your computer and use it in GitHub Desktop.
Simple Button Example
This file contains 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
#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