diff --git a/MSSimpleGauge.podspec b/MSSimpleGauge.podspec new file mode 100644 index 0000000..6263508 --- /dev/null +++ b/MSSimpleGauge.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = "MSSimpleGauge" + s.version = "0.3.1" + s.summary = "Gauge like widget views for iOS. With iOS 5 compatibility fixes." + s.homepage = "https://github.com/sabymike/MSSimpleGauge" + s.screenshots = "https://raw.github.com/sabymike/MSSimpleGauge/master/SimpleGauge/simple.png", "https://raw.github.com/sabymike/MSSimpleGauge/master/SimpleGauge/range.png", "https://raw.github.com/sabymike/MSSimpleGauge/master/SimpleGauge/annotated.png" + s.license = 'MIT' + s.author = { "Mike Sabatini" => "mike@parallelboxes.com" } + s.source = { :git => "https://github.com/paulz/MSSimpleGauge.git", :branch => "ios5" } + s.platform = :ios, '5.0' + s.source_files = 'SimpleGauge/Gauges/*.{h,m}' + s.frameworks = 'QuartzCore', 'UIKit', 'CoreGraphics', 'Foundation' + s.requires_arc = true +end diff --git a/MSSimpleGauge.xcodeproj/project.pbxproj b/MSSimpleGauge.xcodeproj/project.pbxproj index 7976f9f..690cf2d 100644 --- a/MSSimpleGauge.xcodeproj/project.pbxproj +++ b/MSSimpleGauge.xcodeproj/project.pbxproj @@ -33,6 +33,12 @@ 347CB51D1775EFB2009F5D52 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 347CB51B1775EFB2009F5D52 /* README.md */; }; 34BED3ED16AD81DD00034301 /* MSRangeGauge.m in Sources */ = {isa = PBXBuildFile; fileRef = 34BED3EC16AD81DD00034301 /* MSRangeGauge.m */; }; 34E83E6E16B95D600041F046 /* MSAnnotatedGauge.m in Sources */ = {isa = PBXBuildFile; fileRef = 34E83E6D16B95D600041F046 /* MSAnnotatedGauge.m */; }; + 4BB87D95178D2227002B7980 /* tab_bar_icon_annotated.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D93178D2227002B7980 /* tab_bar_icon_annotated.png */; }; + 4BB87D96178D2227002B7980 /* tab_bar_icon_annotated@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D94178D2227002B7980 /* tab_bar_icon_annotated@2x.png */; }; + 4BB87D9B178D24A2002B7980 /* tab_bar_icon_range.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D97178D24A1002B7980 /* tab_bar_icon_range.png */; }; + 4BB87D9C178D24A2002B7980 /* tab_bar_icon_range@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D98178D24A1002B7980 /* tab_bar_icon_range@2x.png */; }; + 4BB87D9D178D24A2002B7980 /* tab_bar_icon_simple.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D99178D24A1002B7980 /* tab_bar_icon_simple.png */; }; + 4BB87D9E178D24A2002B7980 /* tab_bar_icon_simple@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4BB87D9A178D24A2002B7980 /* tab_bar_icon_simple@2x.png */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -78,6 +84,12 @@ 34BED3EF16AD824D00034301 /* MSSimpleGaugeSubclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MSSimpleGaugeSubclass.h; path = Gauges/MSSimpleGaugeSubclass.h; sourceTree = ""; }; 34E83E6C16B95D600041F046 /* MSAnnotatedGauge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MSAnnotatedGauge.h; path = Gauges/MSAnnotatedGauge.h; sourceTree = ""; }; 34E83E6D16B95D600041F046 /* MSAnnotatedGauge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MSAnnotatedGauge.m; path = Gauges/MSAnnotatedGauge.m; sourceTree = ""; }; + 4BB87D93178D2227002B7980 /* tab_bar_icon_annotated.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tab_bar_icon_annotated.png; sourceTree = ""; }; + 4BB87D94178D2227002B7980 /* tab_bar_icon_annotated@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_bar_icon_annotated@2x.png"; sourceTree = ""; }; + 4BB87D97178D24A1002B7980 /* tab_bar_icon_range.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tab_bar_icon_range.png; sourceTree = ""; }; + 4BB87D98178D24A1002B7980 /* tab_bar_icon_range@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_bar_icon_range@2x.png"; sourceTree = ""; }; + 4BB87D99178D24A1002B7980 /* tab_bar_icon_simple.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tab_bar_icon_simple.png; sourceTree = ""; }; + 4BB87D9A178D24A2002B7980 /* tab_bar_icon_simple@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_bar_icon_simple@2x.png"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -149,6 +161,12 @@ 342338CB169E39EA008C3A20 /* Default.png */, 342338CD169E39EA008C3A20 /* Default@2x.png */, 342338CF169E39EA008C3A20 /* Default-568h@2x.png */, + 4BB87D97178D24A1002B7980 /* tab_bar_icon_range.png */, + 4BB87D98178D24A1002B7980 /* tab_bar_icon_range@2x.png */, + 4BB87D99178D24A1002B7980 /* tab_bar_icon_simple.png */, + 4BB87D9A178D24A2002B7980 /* tab_bar_icon_simple@2x.png */, + 4BB87D93178D2227002B7980 /* tab_bar_icon_annotated.png */, + 4BB87D94178D2227002B7980 /* tab_bar_icon_annotated@2x.png */, ); name = "Supporting Files"; sourceTree = ""; @@ -278,6 +296,12 @@ 3470E0EE1774E6B900772821 /* simple.png in Resources */, 347CB51C1775EFB2009F5D52 /* LICENSE.txt in Resources */, 347CB51D1775EFB2009F5D52 /* README.md in Resources */, + 4BB87D95178D2227002B7980 /* tab_bar_icon_annotated.png in Resources */, + 4BB87D96178D2227002B7980 /* tab_bar_icon_annotated@2x.png in Resources */, + 4BB87D9B178D24A2002B7980 /* tab_bar_icon_range.png in Resources */, + 4BB87D9C178D24A2002B7980 /* tab_bar_icon_range@2x.png in Resources */, + 4BB87D9D178D24A2002B7980 /* tab_bar_icon_simple.png in Resources */, + 4BB87D9E178D24A2002B7980 /* tab_bar_icon_simple@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -375,6 +399,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SimpleGauge/MSSimpleGauge-Prefix.pch"; INFOPLIST_FILE = "SimpleGauge/MSSimpleGauge-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = MSSimpleGauge; WRAPPER_EXTENSION = app; }; @@ -386,6 +411,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SimpleGauge/MSSimpleGauge-Prefix.pch"; INFOPLIST_FILE = "SimpleGauge/MSSimpleGauge-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = MSSimpleGauge; WRAPPER_EXTENSION = app; }; diff --git a/SimpleGauge/DemoViewControllers/iPhone.storyboard b/SimpleGauge/DemoViewControllers/iPhone.storyboard index 287ec49..53e6763 100644 --- a/SimpleGauge/DemoViewControllers/iPhone.storyboard +++ b/SimpleGauge/DemoViewControllers/iPhone.storyboard @@ -1,5 +1,5 @@ - + @@ -13,10 +13,8 @@ - - - - - - - - - - - - - - - + @@ -101,26 +86,20 @@ - - - - - - - - - - - - - - - - + @@ -209,10 +171,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - + @@ -347,6 +282,11 @@ + + + + + @@ -366,9 +306,6 @@ - - - diff --git a/SimpleGauge/Gauges/MSAnnotatedGauge.m b/SimpleGauge/Gauges/MSAnnotatedGauge.m index bee8157..e656c47 100644 --- a/SimpleGauge/Gauges/MSAnnotatedGauge.m +++ b/SimpleGauge/Gauges/MSAnnotatedGauge.m @@ -34,7 +34,9 @@ - (id)initWithFrame:(CGRect)frame _titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.backgroundColor = [UIColor clearColor]; _titleLabel.textColor = [UIColor lightGrayColor]; - _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; + if ([_titleLabel respondsToSelector:@selector(setTranslatesAutoresizingMaskIntoConstraints:)]) { + _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; + } [self addSubview:_titleLabel]; UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _titleLabel.frame.size.height, frame.size.width, 28)]; @@ -42,12 +44,20 @@ - (id)initWithFrame:(CGRect)frame _valueLabel.font = [UIFont boldSystemFontOfSize:32]; _valueLabel.textAlignment = NSTextAlignmentCenter; _valueLabel.backgroundColor = [UIColor clearColor]; - _valueLabel.translatesAutoresizingMaskIntoConstraints = NO; + if ([_valueLabel respondsToSelector:@selector(setTranslatesAutoresizingMaskIntoConstraints:)]) { + _valueLabel.translatesAutoresizingMaskIntoConstraints = NO; + } [self addSubview:_valueLabel]; - NSDictionary *views = NSDictionaryOfVariableBindings(titleLabel, valueLabel); - NSArray *contraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-5-[titleLabel(==12)]-0-[valueLabel(==32)]" options:0 metrics:nil views:views]; - [self addConstraints:contraints]; + if ([NSLayoutConstraint class]) { + NSDictionary *views = NSDictionaryOfVariableBindings(titleLabel, valueLabel); + NSString *visualFormat = @"V:|-5-[titleLabel(==12)]-0-[valueLabel(==32)]"; + NSArray *contraint = [NSLayoutConstraint constraintsWithVisualFormat:visualFormat + options:0 + metrics:nil + views:views]; + [self addConstraints:contraint]; + } CGPoint innerArcStartPoint = [self.backgroundArcLayer pointForArcEdge:ArcEdgeInner andArcSide:ArcSideBegining]; _startRangeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, innerArcStartPoint.y+4, innerArcStartPoint.x, 14)]; diff --git a/SimpleGauge/tab_bar_icon_annotated.png b/SimpleGauge/tab_bar_icon_annotated.png new file mode 100644 index 0000000..5a9859c Binary files /dev/null and b/SimpleGauge/tab_bar_icon_annotated.png differ diff --git a/SimpleGauge/tab_bar_icon_annotated@2x.png b/SimpleGauge/tab_bar_icon_annotated@2x.png new file mode 100644 index 0000000..b2b407b Binary files /dev/null and b/SimpleGauge/tab_bar_icon_annotated@2x.png differ diff --git a/SimpleGauge/tab_bar_icon_range.png b/SimpleGauge/tab_bar_icon_range.png new file mode 100644 index 0000000..7863b3c Binary files /dev/null and b/SimpleGauge/tab_bar_icon_range.png differ diff --git a/SimpleGauge/tab_bar_icon_range@2x.png b/SimpleGauge/tab_bar_icon_range@2x.png new file mode 100644 index 0000000..88d3a9a Binary files /dev/null and b/SimpleGauge/tab_bar_icon_range@2x.png differ diff --git a/SimpleGauge/tab_bar_icon_simple.png b/SimpleGauge/tab_bar_icon_simple.png new file mode 100644 index 0000000..40d104b Binary files /dev/null and b/SimpleGauge/tab_bar_icon_simple.png differ diff --git a/SimpleGauge/tab_bar_icon_simple@2x.png b/SimpleGauge/tab_bar_icon_simple@2x.png new file mode 100644 index 0000000..8e5df83 Binary files /dev/null and b/SimpleGauge/tab_bar_icon_simple@2x.png differ