diff --git a/README.md b/README.md index d63f2bb..3392f3a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ I use Snapshot Stack View to display a thumbnail to the user within an article f Compatability ------------- -Snapshot Stack View has been developed to run on iOS 3.2 or later (Deployment Target) and was developed using iOS SDK 5.0, Xcode 4.2.1 (Base SDK). +Snapshot Stack View has been developed to run on iOS 3.1 or later (Deployment Target) and was developed using iOS SDK 5.0, Xcode 4.2.1 (Base SDK). Support for iOS 3 was required for the target application I initially developed Snapshot Stack View for and hence Snapshot Stack View does NOT make use of any of the newer iOS features such as blocks or more importantly Automatic Reference Counting (ARC). diff --git a/SWSnapshotStackView.h b/SWSnapshotStackView.h index bc0d019..5359216 100644 --- a/SWSnapshotStackView.h +++ b/SWSnapshotStackView.h @@ -29,8 +29,7 @@ ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ** - ** Open Source Initiative OSI - The MIT License, - ** see . + ** MIT License, see . ** ** \see SNWSnapshotStackView.m */ @@ -39,7 +38,7 @@ // // Project : iOS Common Components // Component : GUI/Views -// Platform : iOS SDK 3.0+ +// Platform : iOS SDK 3.1+ // //////////////////////////////////////////////////////////////////////////// @@ -120,6 +119,14 @@ SnapshotPosition_t; //! Minimum scaling factor was calculated using image width (YES) otherwise //! height (NO), stored to avoid recalculation and comparison when drawing. BOOL m_scaledUsingWidth; + + //! Shadow Direction Sign + //! Support for inversion of shadow base translation, y-axis in iOS 3.2+ + //! Stored to avoid having to recheck system OS version during redrawing etc. + //! In <3.2, positive y, translates shadow DOWN + //! In 3.2+, positive y, translates shadow UP + //! NOTE: Not required if you do not wish to support iOS <3.2 + CGFloat m_shadowDirSign; } diff --git a/SWSnapshotStackView.m b/SWSnapshotStackView.m index 7f51bf4..2c74e06 100644 --- a/SWSnapshotStackView.m +++ b/SWSnapshotStackView.m @@ -38,7 +38,7 @@ // // Project : iOS Common Components // Component : GUI/Views -// Platform : iOS SDK 3.0+ +// Platform : iOS SDK 3.1+ // //////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ // SNAPSHOT STACK VIEW CLASS (PRIVATE METHODS) // ********************************************************************** // -#pragma mark Snapshot Stack View class (Private Methods) +#pragma mark Snapshot Stack View class (Private Interface) @interface SWSnapshotStackView (Private) @@ -221,6 +221,14 @@ - (void)commonInitialisation // View's background is transparent underneath the rendered snapshot(s) self.backgroundColor = [UIColor clearColor]; + + // Check system (iOS) version, invert sign of shadow direction when + // running on iOS <3.2 + m_shadowDirSign = 1.0; + if (NSOrderedAscending == [[[UIDevice currentDevice] systemVersion] compare:@"3.2" options:NSNumericSearch]) + { + m_shadowDirSign = -1.0; + } } @@ -314,7 +322,7 @@ - (void)drawRect:(CGRect)rect // Draw the shadow using it's calculated path colour = [UIColor colorWithRed:0 green:0 blue:0.0 alpha:0.6]; - CGContextSetShadowWithColor (context, CGSizeMake (0, SWSnapshotStackViewSingleShadowYOffset), + CGContextSetShadowWithColor (context, CGSizeMake (0, (SWSnapshotStackViewSingleShadowYOffset * m_shadowDirSign)), SWSnapshotStackViewSingleShadowRadius, colour.CGColor); CGContextAddPath (context, shadowPath); CGContextFillPath (context); @@ -432,7 +440,7 @@ - (void)drawRect:(CGRect)rect // slightly. Still not 100% happy with the shadow drawing, plan // to tweak eventually to get better end effect colour = [UIColor colorWithRed:0 green:0 blue:0.0 alpha:0.4]; - CGContextSetShadowWithColor (context, CGSizeMake (0.0, SWSnapshotStackViewStackShadowYOffset), + CGContextSetShadowWithColor (context, CGSizeMake (0.0, (SWSnapshotStackViewStackShadowYOffset * m_shadowDirSign)), SWSnapshotStackViewStackShadowRadius, colour.CGColor); CGContextAddPath (context, matteFramePath); CGContextFillPath (context); diff --git a/SWSnapshotStackViewDemo/SWSnapshotStackViewDemo.xcodeproj/project.pbxproj b/SWSnapshotStackViewDemo/SWSnapshotStackViewDemo.xcodeproj/project.pbxproj index f04e000..1bd6ff8 100644 --- a/SWSnapshotStackViewDemo/SWSnapshotStackViewDemo.xcodeproj/project.pbxproj +++ b/SWSnapshotStackViewDemo/SWSnapshotStackViewDemo.xcodeproj/project.pbxproj @@ -231,7 +231,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = ( + armv6, + "$(ARCHS_STANDARD_32_BIT)", + ); "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -246,7 +249,7 @@ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; SDKROOT = iphoneos; }; name = Debug; @@ -255,7 +258,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = ( + armv6, + "$(ARCHS_STANDARD_32_BIT)", + ); "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -263,7 +269,7 @@ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -276,8 +282,9 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SWSnapshotStackViewDemo/SWSnapshotStackViewDemo-Prefix.pch"; INFOPLIST_FILE = "SWSnapshotStackViewDemo/SWSnapshotStackViewDemo-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; name = Debug; @@ -288,8 +295,9 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SWSnapshotStackViewDemo/SWSnapshotStackViewDemo-Prefix.pch"; INFOPLIST_FILE = "SWSnapshotStackViewDemo/SWSnapshotStackViewDemo-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; name = Release;