Skip to content

Instantly share code, notes, and snippets.

#import <UIKit/UIKit.h>
@interface UIBarButtonItem (Todd)
@property (assign, nonatomic, getter = isSelected) BOOL selected;
- (instancetype)initWithImageName:(NSString *)imageName target:(id)target selector:(SEL)selector;
- (instancetype)initWithImageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName target:(id)target selector:(SEL)selector;
@end
@toddlee
toddlee / masking-image.m
Created October 10, 2012 08:02
Masking a UIImage with a mask UIImage in iOS
- (UIImage *)maskImage:(UIImage *)image withMask:(UIImage *)maskImage
{
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);