Skip to content

Instantly share code, notes, and snippets.

@markd2
Created September 17, 2012 20:07
Show Gist options
  • Save markd2/3739473 to your computer and use it in GitHub Desktop.
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.
@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