Skip to content

Instantly share code, notes, and snippets.

@n8gray
Created June 25, 2014 04:59
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 n8gray/56383833d15764c9ac70 to your computer and use it in GitHub Desktop.
Save n8gray/56383833d15764c9ac70 to your computer and use it in GitHub Desktop.
No Jerry, I'm not fucking with you
// At some point I thought this was very clever
//
// Six months later I was like, why the hell is the tag on this view 1008017??!?!
-(void)awakeFromNib
{
[super awakeFromNib];
int tag = [self tag];
if (tag > 1000000) {
int residue = tag - (tag / 1000000) * 1000000;
int leftCap = residue / 1000;
int topCap = residue - 1000 * leftCap;
UIImage *img;
img = [self backgroundImageForState:UIControlStateNormal];
if (img) {
img = [img stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
[self setBackgroundImage:img forState:UIControlStateNormal];
}
img = [self backgroundImageForState:UIControlStateHighlighted];
if (img) {
img = [img stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
[self setBackgroundImage:img forState:UIControlStateHighlighted];
}
img = [self backgroundImageForState:UIControlStateSelected];
if (img) {
img = [img stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
[self setBackgroundImage:img forState:UIControlStateSelected];
}
img = [self backgroundImageForState:UIControlStateDisabled];
if (img) {
img = [img stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
[self setBackgroundImage:img forState:UIControlStateDisabled];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment