Created
November 30, 2012 08:30
-
-
Save terut/4174526 to your computer and use it in GitHub Desktop.
UIButton background for state
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
- (void)setBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state | |
{ | |
CGRect rect = CGRectMake(0, 0, 1, 1); | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(context, backgroundColor.CGColor); | |
CGContextFillRect(context, rect); | |
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
[self setBackgroundImage:backgroundImage forState:state]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment