diff --git a/LMAlertView/LMAlertView.m b/LMAlertView/LMAlertView.m index 2ad40d3..dd65982 100644 --- a/LMAlertView/LMAlertView.m +++ b/LMAlertView/LMAlertView.m @@ -10,6 +10,7 @@ #import "LMEmbeddedViewController.h" #import "LMModalItemTableViewCell.h" #import +#import "UIDevice+SystemVersionNumber.h" @interface LMAlertView () @@ -114,7 +115,9 @@ - (void)setButtonsShouldStack:(BOOL)buttonsShouldStack - (void)setTintColor:(UIColor *)tintColor { _tintColor = tintColor; - self.window.tintColor = tintColor; + + if([UIDevice currentDevice].systemVersionNumber >= 7.0) + self.window.tintColor = tintColor; } - (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... @@ -430,7 +433,8 @@ - (void)show // You can have more than one UIWindow in the view hierachy, which is how UIAlertView works self.window = [[UIWindow alloc] initWithFrame:[appDelegate window].frame]; - self.window.tintColor = self.tintColor; + if([UIDevice currentDevice].systemVersionNumber >= 7.0) + self.window.tintColor = self.tintColor; LMEmbeddedViewController *viewController = [[LMEmbeddedViewController alloc] init]; viewController.alertView = self; diff --git a/LMAlertView/UIDevice+SystemVersionNumber.h b/LMAlertView/UIDevice+SystemVersionNumber.h new file mode 100644 index 0000000..ebc205d --- /dev/null +++ b/LMAlertView/UIDevice+SystemVersionNumber.h @@ -0,0 +1,14 @@ +// +// UIDevice+SystemVersionNumber.h +// LMAlertViewDemo +// +// Created by Lin Cheng Kai on 14/4/24. +// Copyright (c) 2014年 Bestir Ltd. All rights reserved. +// + +#import + +@interface UIDevice (SystemVersionNumber) +@property (nonatomic, readonly) float systemVersionNumber; + +@end diff --git a/LMAlertView/UIDevice+SystemVersionNumber.m b/LMAlertView/UIDevice+SystemVersionNumber.m new file mode 100644 index 0000000..76e1204 --- /dev/null +++ b/LMAlertView/UIDevice+SystemVersionNumber.m @@ -0,0 +1,33 @@ +// +// UIDevice+SystemVersionNumber.m +// LMAlertViewDemo +// +// Created by Lin Cheng Kai on 14/4/24. +// Copyright (c) 2014年 Bestir Ltd. All rights reserved. +// + +#import "UIDevice+SystemVersionNumber.h" +#import + +const char SYS_VER_NUM_KEY; +@implementation UIDevice (SystemVersionNumber) +- (float)systemVersionNumber +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSString *sysVer = [UIDevice currentDevice].systemVersion; + NSError *error = nil; + NSRegularExpression *regexp =[NSRegularExpression regularExpressionWithPattern:@"\\d.\\d" options:0 error:&error]; + NSTextCheckingResult *result = [regexp firstMatchInString:sysVer options:0 range:NSMakeRange(0, [sysVer length])]; + + NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; + numFormatter.numberStyle = NSNumberFormatterDecimalStyle; + NSNumber *versionNumber = [numFormatter numberFromString:[sysVer substringWithRange:result.range]]; + + objc_setAssociatedObject(self, &SYS_VER_NUM_KEY, versionNumber, OBJC_ASSOCIATION_ASSIGN); + }); + + NSNumber *sysVerNum = objc_getAssociatedObject(self, &SYS_VER_NUM_KEY); + return [sysVerNum floatValue]; +} +@end diff --git a/LMAlertViewDemo.xcodeproj/project.pbxproj b/LMAlertViewDemo.xcodeproj/project.pbxproj index 5bacd19..692bcb5 100644 --- a/LMAlertViewDemo.xcodeproj/project.pbxproj +++ b/LMAlertViewDemo.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 16CCDFA91853296D0059DE8B /* LMTwitterLocationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16CCDFA81853296D0059DE8B /* LMTwitterLocationViewController.m */; }; 16CCDFAC18544C6F0059DE8B /* LMNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16CCDFAB18544C6F0059DE8B /* LMNavigationController.m */; }; 16CCDFD2185832520059DE8B /* LMModalItemTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 16CCDFD1185832520059DE8B /* LMModalItemTableViewCell.m */; }; + 984508EE19090DFA0017DE75 /* UIDevice+SystemVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 984508ED19090DFA0017DE75 /* UIDevice+SystemVersionNumber.m */; }; E017F5E695B446B2B1B5314D /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B6ABB7B0B6944B929C0CFAFE /* libPods.a */; }; /* End PBXBuildFile section */ @@ -67,6 +68,8 @@ 16CCDFD0185832520059DE8B /* LMModalItemTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LMModalItemTableViewCell.h; path = ../LMAlertView/LMModalItemTableViewCell.h; sourceTree = ""; }; 16CCDFD1185832520059DE8B /* LMModalItemTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LMModalItemTableViewCell.m; path = ../LMAlertView/LMModalItemTableViewCell.m; sourceTree = ""; }; 1FE7E8F0E7304B2287950B17 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; }; + 984508EC19090DFA0017DE75 /* UIDevice+SystemVersionNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+SystemVersionNumber.h"; path = "LMAlertView/UIDevice+SystemVersionNumber.h"; sourceTree = SOURCE_ROOT; }; + 984508ED19090DFA0017DE75 /* UIDevice+SystemVersionNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+SystemVersionNumber.m"; path = "LMAlertView/UIDevice+SystemVersionNumber.m"; sourceTree = SOURCE_ROOT; }; B6ABB7B0B6944B929C0CFAFE /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -173,6 +176,8 @@ 16CCDFAA18544C6F0059DE8B /* LMNavigationController.h */, 16CCDFAB18544C6F0059DE8B /* LMNavigationController.m */, 169103CD183311F3003DF9E6 /* Radial.png */, + 984508EC19090DFA0017DE75 /* UIDevice+SystemVersionNumber.h */, + 984508ED19090DFA0017DE75 /* UIDevice+SystemVersionNumber.m */, ); name = LMAlertView; path = LMAlertViewDemo; @@ -285,6 +290,7 @@ 16CCDFAC18544C6F0059DE8B /* LMNavigationController.m in Sources */, 16CCDFA91853296D0059DE8B /* LMTwitterLocationViewController.m in Sources */, 16B47FC7183A33E800A06371 /* CALayer+ModalAlert.m in Sources */, + 984508EE19090DFA0017DE75 /* UIDevice+SystemVersionNumber.m in Sources */, 16CCDFD2185832520059DE8B /* LMModalItemTableViewCell.m in Sources */, 165F9F781831632C00037E82 /* main.m in Sources */, 165F9F7C1831632C00037E82 /* LMAppDelegate.m in Sources */, diff --git a/Podfile.lock b/Podfile.lock index 88b5970..c2ec018 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :git: https://github.com/lmcd/LMFixedTextView.git SPEC CHECKSUMS: - CAAnimationBlocks: b70f877c5b92734abef270152187d3287d84e8f8 - EDStarRating: 6761f41fd040f1cde155e2885dddc96461620f67 + CAAnimationBlocks: 0b18c88fcdffc0b8bb5e4c2ef57096f85119bb4d + EDStarRating: 4954b62647884e7b2d37c4720d4a1f758b5a3435 LMFixedTextView: 794f1423096e30f88a856ef49a791af08e5c6efe RBBAnimation: e7f31ed62f760f3caf120b5d943267bd9a8e1f64 -COCOAPODS: 0.28.0 +COCOAPODS: 0.32.1