Saturday, March 2, 2013

Метод изменения картинки


#import <QuartzCore/QuartzCore.h>
addProjectBtn setImage:[Helper getImageWithColor:[UIColor colorWithWhite:0.0 alpha:0.1] withSize:addProjectBtn.frame.size] forState:UIControlStateHighlighted];

+ (UIImage *)getImageWithColor:(UIColor *)color withSize:(CGSize)size{
    
    UIGraphicsBeginImageContext(size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColor(context, CGColorGetComponents(color.CGColor));
CGContextFillRect(context, CGRectMake(0, 0, size.width, size.height));
    
    UIImage *i = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return i;
}

No comments:

Post a Comment