From 5cd05b1e1416b7b65b55ae58940f34599af07d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Fri, 4 Mar 2011 06:48:45 +0800 Subject: [PATCH] Builtin images are back --- Classes/AQGridViewCell.m | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Classes/AQGridViewCell.m b/Classes/AQGridViewCell.m index dd7814b..d075e6d 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 ) { @@ -322,6 +355,7 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated } _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]]; +#endif _selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; _selectedBackgroundView.contentMode = UIViewContentModeScaleToFill; }