Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Embed all AQGridSelection* pngs

  • Loading branch information...
commit aee526a5b6cf12525057df44d512e15f5e2a65d7 1 parent 52e6cfb
@0xced 0xced authored committed
View
24 AQGridView.xcodeproj/project.pbxproj
@@ -193,6 +193,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "AQGridView" */;
buildPhases = (
+ DA62444512102F6E007EC097 /* Embed PNGs */,
D2AAC07A0554694100DB518D /* Headers */,
D2AAC07B0554694100DB518D /* Sources */,
D2AAC07C0554694100DB518D /* Frameworks */,
@@ -224,6 +225,29 @@
};
/* End PBXProject section */
+/* Begin PBXShellScriptBuildPhase section */
+ DA62444512102F6E007EC097 /* Embed PNGs */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 12;
+ files = (
+ );
+ inputPaths = (
+ "$(SRCROOT)/Resources/AQGridSelection.png",
+ "$(SRCROOT)/Resources/AQGridSelectionGray.png",
+ "$(SRCROOT)/Resources/AQGridSelectionGrayBlue.png",
+ "$(SRCROOT)/Resources/AQGridSelectionGreen.png",
+ "$(SRCROOT)/Resources/AQGridSelectionRed.png",
+ );
+ name = "Embed PNGs";
+ outputPaths = (
+ "$(DERIVED_FILES_DIR)/AQGridViewCell_png.h",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/bash;
+ shellScript = ". \"${SRCROOT}/Scripts/embed_png.sh\"\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
D2AAC07B0554694100DB518D /* Sources */ = {
isa = PBXSourcesBuildPhase;
View
20 Classes/AQGridViewCell.m
@@ -38,7 +38,7 @@
#import "AQGridViewCell+AQGridViewCellPrivate.h"
#import "UIColor+AQGridView.h"
#import <QuartzCore/QuartzCore.h>
-#import <objc/runtime.h>
+#import "AQGridViewCell_png.h"
@interface AQGridViewCell ()
@property (nonatomic, retain) UIView * contentView;
@@ -297,7 +297,8 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
{
if ( (_cellFlags.usingDefaultSelectedBackgroundView == 1) && (_selectedBackgroundView == nil) )
{
- NSString * imageName = @"AQGridSelection.png";
+ unsigned char * pngBytes = AQGridSelection_png;
+ NSUInteger pngLength = AQGridSelection_png_len;
switch ( _cellFlags.selectionStyle )
{
case AQGridViewCellSelectionStyleBlue:
@@ -305,23 +306,28 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
break;
case AQGridViewCellSelectionStyleGray:
- imageName = @"AQGridSelectionGray.png";
+ pngBytes = AQGridSelectionGray_png;
+ pngLength = AQGridSelectionGray_png_len;
break;
case AQGridViewCellSelectionStyleBlueGray:
- imageName = @"AQGridSelectionGrayBlue.png";
+ pngBytes = AQGridSelectionGrayBlue_png;
+ pngLength = AQGridSelectionGrayBlue_png_len;
break;
case AQGridViewCellSelectionStyleGreen:
- imageName = @"AQGridSelectionGreen.png";
+ pngBytes = AQGridSelectionGreen_png;
+ pngLength = AQGridSelectionGreen_png_len;
break;
case AQGridViewCellSelectionStyleRed:
- imageName = @"AQGridSelectionRed.png";
+ pngBytes = AQGridSelectionRed_png;
+ pngLength = AQGridSelectionRed_png_len;
break;
}
- _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
+ NSData *pngData = [NSData dataWithBytesNoCopy: pngBytes length: pngLength freeWhenDone: NO];
+ _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageWithData: pngData]];
_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_selectedBackgroundView.contentMode = UIViewContentModeScaleToFill;
}
View
11 Scripts/embed_png.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+PNG_HEADER="${DERIVED_FILES_DIR}/AQGridViewCell_png.h"
+
+rm -f "${PNG_HEADER}"
+mkdir -p "${DERIVED_FILES_DIR}"
+
+cd Resources
+for png in *; do
+ xxd -i "$png" >> "${PNG_HEADER}"
+done
Please sign in to comment.
Something went wrong with that request. Please try again.