Skip to content

Instantly share code, notes, and snippets.

@rbaulin
Last active December 17, 2015 17:49
Show Gist options
  • Save rbaulin/5649290 to your computer and use it in GitHub Desktop.
Save rbaulin/5649290 to your computer and use it in GitHub Desktop.
Colorize view stack, useful for frame inspection
// example: [self colorizeStack:self.view];
- (void)colorizeStack:(UIView *)view {
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:0.8];
view.backgroundColor = color;
for (UIView *subView in view.subviews) {
[self colorizeStack:subView];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment