diff --git a/Classes/AQGridViewCell.m b/Classes/AQGridViewCell.m index 0464784..a875a76 100644 --- a/Classes/AQGridViewCell.m +++ b/Classes/AQGridViewCell.m @@ -40,6 +40,10 @@ #import #import +#ifdef BUILTIN_IMAGES +#import "AQGridViewCell_png.h" +#endif + @interface AQGridViewCell () @property (nonatomic, retain) UIView * contentView; @property (nonatomic, copy) NSString * reuseIdentifier; @@ -297,6 +301,35 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated { if ( (_cellFlags.usingDefaultSelectedBackgroundView == 1) && (_selectedBackgroundView == nil) ) { +#ifdef BUILTIN_IMAGES + unsigned char * pngBytes = AQGridSelection_png; + NSUInteger pngLength = AQGridSelection_png_len; + switch ( _cellFlags.selectionStyle ) + { + case AQGridViewCellSelectionStyleBlue: + default: + break; + + case AQGridViewCellSelectionStyleGray: + imageName = @"AQGridSelectionGray.png"; + break; + + case AQGridViewCellSelectionStyleBlueGray: + imageName = @"AQGridSelectionGrayBlue.png"; + break; + + case AQGridViewCellSelectionStyleGreen: + imageName = @"AQGridSelectionGreen.png"; + break; + + case AQGridViewCellSelectionStyleRed: + imageName = @"AQGridSelectionRed.png"; + break; + } + + NSData *pngData = [NSData dataWithBytesNoCopy: pngBytes length: pngLength freeWhenDone: NO]; + _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageWithData: pngData]]; +#else NSString * imageName = @"AQGridSelection.png"; switch ( _cellFlags.selectionStyle ) { @@ -326,6 +359,7 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated } _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]]; +#endif _selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; _selectedBackgroundView.contentMode = UIViewContentModeScaleToFill; }