Created
September 17, 2012 20:07
-
-
Save markd2/3739473 to your computer and use it in GitHub Desktop.
A simple UIView that draws itself in a color based on its address in memory.
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
@interface BlahView : UIView | |
@end | |
@implementation BlahView | |
- (void) drawRect: (CGRect) rect { | |
CGRect bounds = self.bounds; | |
UIColor *color = [UIColor colorWithRed: (((int)self) & 0xFF) / 255.0 | |
green: (((int)self >> 8) & 0xFF) / 255.0 | |
blue: (((int)self >> 16) & 0xFF) / 255.0 | |
alpha: 1.0]; | |
[color set]; | |
UIRectFill(bounds); | |
[[UIColor blackColor] set]; | |
UIRectFrame(bounds); | |
} // drawRect | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment