Skip to content
This repository
Browse code

Embed all AQGridSelection* pngs

  • Loading branch information...
commit aee526a5b6cf12525057df44d512e15f5e2a65d7 1 parent 52e6cfb
Cédric Luthi authored AlanQuatermain committed
24  AQGridView.xcodeproj/project.pbxproj
@@ -193,6 +193,7 @@
193 193
 			isa = PBXNativeTarget;
194 194
 			buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "AQGridView" */;
195 195
 			buildPhases = (
  196
+				DA62444512102F6E007EC097 /* Embed PNGs */,
196 197
 				D2AAC07A0554694100DB518D /* Headers */,
197 198
 				D2AAC07B0554694100DB518D /* Sources */,
198 199
 				D2AAC07C0554694100DB518D /* Frameworks */,
@@ -224,6 +225,29 @@
224 225
 		};
225 226
 /* End PBXProject section */
226 227
 
  228
+/* Begin PBXShellScriptBuildPhase section */
  229
+		DA62444512102F6E007EC097 /* Embed PNGs */ = {
  230
+			isa = PBXShellScriptBuildPhase;
  231
+			buildActionMask = 12;
  232
+			files = (
  233
+			);
  234
+			inputPaths = (
  235
+				"$(SRCROOT)/Resources/AQGridSelection.png",
  236
+				"$(SRCROOT)/Resources/AQGridSelectionGray.png",
  237
+				"$(SRCROOT)/Resources/AQGridSelectionGrayBlue.png",
  238
+				"$(SRCROOT)/Resources/AQGridSelectionGreen.png",
  239
+				"$(SRCROOT)/Resources/AQGridSelectionRed.png",
  240
+			);
  241
+			name = "Embed PNGs";
  242
+			outputPaths = (
  243
+				"$(DERIVED_FILES_DIR)/AQGridViewCell_png.h",
  244
+			);
  245
+			runOnlyForDeploymentPostprocessing = 0;
  246
+			shellPath = /bin/bash;
  247
+			shellScript = ". \"${SRCROOT}/Scripts/embed_png.sh\"\n";
  248
+		};
  249
+/* End PBXShellScriptBuildPhase section */
  250
+
227 251
 /* Begin PBXSourcesBuildPhase section */
228 252
 		D2AAC07B0554694100DB518D /* Sources */ = {
229 253
 			isa = PBXSourcesBuildPhase;
20  Classes/AQGridViewCell.m
@@ -38,7 +38,7 @@
38 38
 #import "AQGridViewCell+AQGridViewCellPrivate.h"
39 39
 #import "UIColor+AQGridView.h"
40 40
 #import <QuartzCore/QuartzCore.h>
41  
-#import <objc/runtime.h>
  41
+#import "AQGridViewCell_png.h"
42 42
 
43 43
 @interface AQGridViewCell ()
44 44
 @property (nonatomic, retain) UIView * contentView;
@@ -297,7 +297,8 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
297 297
 {
298 298
 	if ( (_cellFlags.usingDefaultSelectedBackgroundView == 1) && (_selectedBackgroundView == nil) )
299 299
 	{
300  
-		NSString * imageName = @"AQGridSelection.png";
  300
+		unsigned char * pngBytes = AQGridSelection_png;
  301
+		NSUInteger pngLength = AQGridSelection_png_len;
301 302
 		switch ( _cellFlags.selectionStyle )
302 303
 		{
303 304
 			case AQGridViewCellSelectionStyleBlue:
@@ -305,23 +306,28 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
305 306
 				break;
306 307
 				
307 308
 			case AQGridViewCellSelectionStyleGray:
308  
-				imageName = @"AQGridSelectionGray.png";
  309
+				pngBytes = AQGridSelectionGray_png;
  310
+				pngLength = AQGridSelectionGray_png_len;
309 311
 				break;
310 312
 				
311 313
 			case AQGridViewCellSelectionStyleBlueGray:
312  
-				imageName = @"AQGridSelectionGrayBlue.png";
  314
+				pngBytes = AQGridSelectionGrayBlue_png;
  315
+				pngLength = AQGridSelectionGrayBlue_png_len;
313 316
 				break;
314 317
 				
315 318
 			case AQGridViewCellSelectionStyleGreen:
316  
-				imageName = @"AQGridSelectionGreen.png";
  319
+				pngBytes = AQGridSelectionGreen_png;
  320
+				pngLength = AQGridSelectionGreen_png_len;
317 321
 				break;
318 322
 				
319 323
 			case AQGridViewCellSelectionStyleRed:
320  
-				imageName = @"AQGridSelectionRed.png";
  324
+				pngBytes = AQGridSelectionRed_png;
  325
+				pngLength = AQGridSelectionRed_png_len;
321 326
 				break;
322 327
 		}
323 328
 		
324  
-		_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
  329
+		NSData *pngData = [NSData dataWithBytesNoCopy: pngBytes length: pngLength freeWhenDone: NO];
  330
+		_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageWithData: pngData]];
325 331
 		_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
326 332
 		_selectedBackgroundView.contentMode = UIViewContentModeScaleToFill;
327 333
 	}
11  Scripts/embed_png.sh
... ...
@@ -0,0 +1,11 @@
  1
+#!/bin/bash
  2
+
  3
+PNG_HEADER="${DERIVED_FILES_DIR}/AQGridViewCell_png.h"
  4
+
  5
+rm -f "${PNG_HEADER}"
  6
+mkdir -p "${DERIVED_FILES_DIR}"
  7
+
  8
+cd Resources
  9
+for png in *; do
  10
+	xxd -i "$png" >> "${PNG_HEADER}"
  11
+done

0 notes on commit aee526a

Please sign in to comment.
Something went wrong with that request. Please try again.