Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Mar 4, 2011
2 parents 23a5dd6 + 5cd05b1 commit 451cd9d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Classes/AQGridViewCell.m
Expand Up @@ -40,6 +40,10 @@
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>

#ifdef BUILTIN_IMAGES
#import "AQGridViewCell_png.h"
#endif

@interface AQGridViewCell ()
@property (nonatomic, retain) UIView * contentView;
@property (nonatomic, copy) NSString * reuseIdentifier;
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 451cd9d

Please sign in to comment.