Skip to content

Loading…

Builtin images #45

Closed
wants to merge 6 commits into from
Showing with 38 additions and 0 deletions.
  1. +38 −0 Classes/AQGridViewCell.m
View
38 Classes/AQGridViewCell.m
@@ -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;
@@ -297,6 +301,39 @@ - (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:
+ pngBytes = AQGridSelectionGray_png;
+ pngLength = AQGridSelectionGray_png_len;
+ break;
+
+ case AQGridViewCellSelectionStyleBlueGray:
+ pngBytes = AQGridSelectionGrayBlue_png;
+ pngLength = AQGridSelectionGrayBlue_png_len;
+ break;
+
+ case AQGridViewCellSelectionStyleGreen:
+ pngBytes = AQGridSelectionGreen_png;
+ pngLength = AQGridSelectionGreen_png_len;
+ break;
+
+ case AQGridViewCellSelectionStyleRed:
+ pngBytes = AQGridSelectionRed_png;
+ pngLength = AQGridSelectionRed_png_len;
+ 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 +359,7 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
}
_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
+#endif
_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_selectedBackgroundView.contentMode = UIViewContentModeScaleToFill;
}
Something went wrong with that request. Please try again.