diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c3e68b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.mode1v3 +*.pbxuser +*.perspectivev3 +*.xcworkspace +xcuserdata diff --git a/Example/Classes/SAMAppDelegate.h b/Example/Classes/SAMAppDelegate.h new file mode 100644 index 0000000..8403f43 --- /dev/null +++ b/Example/Classes/SAMAppDelegate.h @@ -0,0 +1,13 @@ +// +// SAMAppDelegate.h +// SAMLoadingView +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +@interface SAMAppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/Example/Classes/SAMAppDelegate.m b/Example/Classes/SAMAppDelegate.m new file mode 100644 index 0000000..93de4a4 --- /dev/null +++ b/Example/Classes/SAMAppDelegate.m @@ -0,0 +1,27 @@ +// +// SAMAppDelegate.m +// SAMLoadingView +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +#import "SAMAppDelegate.h" +#import "SAMRootViewController.h" + +@implementation SAMAppDelegate + +@synthesize window = _window; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + + SAMRootViewController *viewController = [[SAMRootViewController alloc] init]; + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:viewController]; + + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + return YES; +} + +@end diff --git a/Example/Classes/SAMRootViewController.h b/Example/Classes/SAMRootViewController.h new file mode 100644 index 0000000..e6bb740 --- /dev/null +++ b/Example/Classes/SAMRootViewController.h @@ -0,0 +1,10 @@ +// +// SAMRootViewController.h +// SAMLoadingView +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +@interface SAMRootViewController : UIViewController +@end diff --git a/Example/Classes/SAMRootViewController.m b/Example/Classes/SAMRootViewController.m new file mode 100644 index 0000000..a6661c4 --- /dev/null +++ b/Example/Classes/SAMRootViewController.m @@ -0,0 +1,24 @@ +// +// SAMRootViewController.m +// SAMLoadingView +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +#import "SAMRootViewController.h" +#import "SAMLoadingView.h" + +@implementation SAMRootViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = @"Loading View"; + + SAMLoadingView *loadingView = [[SAMLoadingView alloc] initWithFrame:self.view.bounds]; + loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + [self.view addSubview:loadingView]; +} + +@end diff --git a/Example/Other Sources/SAMLoadingView-Prefix.pch b/Example/Other Sources/SAMLoadingView-Prefix.pch new file mode 100644 index 0000000..cbe68c3 --- /dev/null +++ b/Example/Other Sources/SAMLoadingView-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'SAMLoadingView' target in the 'SAMLoadingView' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Example/Other Sources/main.m b/Example/Other Sources/main.m new file mode 100644 index 0000000..357aef5 --- /dev/null +++ b/Example/Other Sources/main.m @@ -0,0 +1,18 @@ +// +// main.m +// SAMLoadingView +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +#import + +#import "SAMAppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([SAMAppDelegate class])); + } +} diff --git a/Example/Resources/Default-568h@2x.png b/Example/Resources/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/Example/Resources/Default-568h@2x.png differ diff --git a/Example/Resources/SAMLoadingView-Info.plist b/Example/Resources/SAMLoadingView-Info.plist new file mode 100644 index 0000000..7eeeaf5 --- /dev/null +++ b/Example/Resources/SAMLoadingView-Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.samsoffes.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..147e106 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009-2013 Sam Soffes, http://soff.es + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Readme.markdown b/Readme.markdown new file mode 100644 index 0000000..502ff72 --- /dev/null +++ b/Readme.markdown @@ -0,0 +1,25 @@ +# SAMLoadingView + +Simple loading view for UIKit. + +SAMLoadingView is tested on iOS 6 and requires ARC. Released under the [MIT license](LICENSE). + +## Example + +![Loading View](http://soff.me/QVLy/iOS%20Simulator%20Screen%20shot%20Jul%2025,%202013,%2011.20.38%20PM.png) + +Open up the included Xcode project for an example app. + +## Usage + +``` objc +SAMLoadingView *loadingView = [[SAMLoadingView alloc] initWithFrame:self.view.bounds]; +loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; +[self.view addSubview:loadingView]; +``` + +See the [header](SAMLoadingView/SAMLoadingView.h) for full documentation. + +## Installation + +Simply add the files in the `SAMLoadingView.h` and `SAMLoadingView.m` to your project or add `SAMLoadingView` to your Podfile if you're using CocoaPods. diff --git a/SAMLoadingView.podspec b/SAMLoadingView.podspec new file mode 100644 index 0000000..4139feb --- /dev/null +++ b/SAMLoadingView.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |spec| + spec.name = 'SAMLoadingView' + spec.version = '0.1.0' + spec.authors = {'Sam Soffes' => 'sam@soff.es'} + spec.homepage = 'https://github.com/soffes/SAMLoadingView' + spec.summary = 'Simple loading view for UIKit.' + spec.source = {:git => 'https://github.com/soffes/SAMLoadingView.git', :tag => "v#{spec.version}"} + spec.license = { :type => 'MIT', :file => 'LICENSE' } + + spec.platform = :ios, '6.0' + spec.requires_arc = true + spec.frameworks = 'UIKit', 'CoreGraphics' + spec.source_files = 'SAMLoadingView' +end diff --git a/SAMLoadingView.xcodeproj/project.pbxproj b/SAMLoadingView.xcodeproj/project.pbxproj new file mode 100644 index 0000000..563ad37 --- /dev/null +++ b/SAMLoadingView.xcodeproj/project.pbxproj @@ -0,0 +1,448 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 213FB35317A21E59002EA528 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35217A21E59002EA528 /* UIKit.framework */; }; + 213FB35517A21E59002EA528 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35417A21E59002EA528 /* Foundation.framework */; }; + 213FB35717A21E59002EA528 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35617A21E59002EA528 /* CoreGraphics.framework */; }; + 213FB37117A21E59002EA528 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB37017A21E59002EA528 /* SenTestingKit.framework */; }; + 213FB37217A21E59002EA528 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35217A21E59002EA528 /* UIKit.framework */; }; + 213FB37317A21E59002EA528 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35417A21E59002EA528 /* Foundation.framework */; }; + 213FB38A17A21EB1002EA528 /* SAMLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB38917A21EB1002EA528 /* SAMLoadingView.m */; }; + 213FB38B17A21EB1002EA528 /* SAMLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB38917A21EB1002EA528 /* SAMLoadingView.m */; }; + 213FB39617A21EB7002EA528 /* SAMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB38F17A21EB7002EA528 /* SAMAppDelegate.m */; }; + 213FB39717A21EB7002EA528 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB39117A21EB7002EA528 /* main.m */; }; + 213FB39817A21EB7002EA528 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 213FB39417A21EB7002EA528 /* Default-568h@2x.png */; }; + 213FB3A217A21EBB002EA528 /* SAMLoadingViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB39F17A21EBB002EA528 /* SAMLoadingViewTests.m */; }; + 213FB3A517A221AA002EA528 /* SAMRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 213FB3A417A221AA002EA528 /* SAMRootViewController.m */; }; + 213FB3A617A22567002EA528 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 213FB35617A21E59002EA528 /* CoreGraphics.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 213FB37417A21E59002EA528 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 213FB34717A21E59002EA528 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 213FB34E17A21E59002EA528; + remoteInfo = SAMLoadingView; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 213FB34F17A21E59002EA528 /* SAMLoadingView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SAMLoadingView.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 213FB35217A21E59002EA528 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 213FB35417A21E59002EA528 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 213FB35617A21E59002EA528 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 213FB36F17A21E59002EA528 /* SAMLoadingViewTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SAMLoadingViewTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 213FB37017A21E59002EA528 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 213FB38817A21EB1002EA528 /* SAMLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAMLoadingView.h; sourceTree = ""; }; + 213FB38917A21EB1002EA528 /* SAMLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAMLoadingView.m; sourceTree = ""; }; + 213FB38E17A21EB7002EA528 /* SAMAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAMAppDelegate.h; sourceTree = ""; }; + 213FB38F17A21EB7002EA528 /* SAMAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAMAppDelegate.m; sourceTree = ""; }; + 213FB39117A21EB7002EA528 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 213FB39217A21EB7002EA528 /* SAMLoadingView-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SAMLoadingView-Prefix.pch"; sourceTree = ""; }; + 213FB39417A21EB7002EA528 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 213FB39517A21EB7002EA528 /* SAMLoadingView-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SAMLoadingView-Info.plist"; sourceTree = ""; }; + 213FB39D17A21EBB002EA528 /* SAMLoadingViewTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SAMLoadingViewTests-Info.plist"; sourceTree = ""; }; + 213FB39F17A21EBB002EA528 /* SAMLoadingViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAMLoadingViewTests.m; sourceTree = ""; }; + 213FB3A317A221AA002EA528 /* SAMRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAMRootViewController.h; sourceTree = ""; }; + 213FB3A417A221AA002EA528 /* SAMRootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAMRootViewController.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 213FB34C17A21E59002EA528 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 213FB35317A21E59002EA528 /* UIKit.framework in Frameworks */, + 213FB35517A21E59002EA528 /* Foundation.framework in Frameworks */, + 213FB35717A21E59002EA528 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 213FB36B17A21E59002EA528 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 213FB3A617A22567002EA528 /* CoreGraphics.framework in Frameworks */, + 213FB37117A21E59002EA528 /* SenTestingKit.framework in Frameworks */, + 213FB37217A21E59002EA528 /* UIKit.framework in Frameworks */, + 213FB37317A21E59002EA528 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 213FB34617A21E59002EA528 = { + isa = PBXGroup; + children = ( + 213FB38717A21EB1002EA528 /* SAMLoadingView */, + 213FB38C17A21EB7002EA528 /* Example */, + 213FB39A17A21EBB002EA528 /* Tests */, + 213FB35117A21E59002EA528 /* Frameworks */, + 213FB35017A21E59002EA528 /* Products */, + ); + sourceTree = ""; + }; + 213FB35017A21E59002EA528 /* Products */ = { + isa = PBXGroup; + children = ( + 213FB34F17A21E59002EA528 /* SAMLoadingView.app */, + 213FB36F17A21E59002EA528 /* SAMLoadingViewTests.octest */, + ); + name = Products; + sourceTree = ""; + }; + 213FB35117A21E59002EA528 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 213FB35217A21E59002EA528 /* UIKit.framework */, + 213FB35417A21E59002EA528 /* Foundation.framework */, + 213FB35617A21E59002EA528 /* CoreGraphics.framework */, + 213FB37017A21E59002EA528 /* SenTestingKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 213FB38717A21EB1002EA528 /* SAMLoadingView */ = { + isa = PBXGroup; + children = ( + 213FB38817A21EB1002EA528 /* SAMLoadingView.h */, + 213FB38917A21EB1002EA528 /* SAMLoadingView.m */, + ); + path = SAMLoadingView; + sourceTree = ""; + }; + 213FB38C17A21EB7002EA528 /* Example */ = { + isa = PBXGroup; + children = ( + 213FB38D17A21EB7002EA528 /* Classes */, + 213FB39017A21EB7002EA528 /* Other Sources */, + 213FB39317A21EB7002EA528 /* Resources */, + ); + path = Example; + sourceTree = ""; + }; + 213FB38D17A21EB7002EA528 /* Classes */ = { + isa = PBXGroup; + children = ( + 213FB38E17A21EB7002EA528 /* SAMAppDelegate.h */, + 213FB38F17A21EB7002EA528 /* SAMAppDelegate.m */, + 213FB3A317A221AA002EA528 /* SAMRootViewController.h */, + 213FB3A417A221AA002EA528 /* SAMRootViewController.m */, + ); + path = Classes; + sourceTree = ""; + }; + 213FB39017A21EB7002EA528 /* Other Sources */ = { + isa = PBXGroup; + children = ( + 213FB39117A21EB7002EA528 /* main.m */, + 213FB39217A21EB7002EA528 /* SAMLoadingView-Prefix.pch */, + ); + path = "Other Sources"; + sourceTree = ""; + }; + 213FB39317A21EB7002EA528 /* Resources */ = { + isa = PBXGroup; + children = ( + 213FB39417A21EB7002EA528 /* Default-568h@2x.png */, + 213FB39517A21EB7002EA528 /* SAMLoadingView-Info.plist */, + ); + path = Resources; + sourceTree = ""; + }; + 213FB39A17A21EBB002EA528 /* Tests */ = { + isa = PBXGroup; + children = ( + 213FB39D17A21EBB002EA528 /* SAMLoadingViewTests-Info.plist */, + 213FB39F17A21EBB002EA528 /* SAMLoadingViewTests.m */, + ); + path = Tests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 213FB34E17A21E59002EA528 /* SAMLoadingView */ = { + isa = PBXNativeTarget; + buildConfigurationList = 213FB38117A21E59002EA528 /* Build configuration list for PBXNativeTarget "SAMLoadingView" */; + buildPhases = ( + 213FB34B17A21E59002EA528 /* Sources */, + 213FB34C17A21E59002EA528 /* Frameworks */, + 213FB34D17A21E59002EA528 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SAMLoadingView; + productName = SAMLoadingView; + productReference = 213FB34F17A21E59002EA528 /* SAMLoadingView.app */; + productType = "com.apple.product-type.application"; + }; + 213FB36E17A21E59002EA528 /* SAMLoadingViewTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 213FB38417A21E59002EA528 /* Build configuration list for PBXNativeTarget "SAMLoadingViewTests" */; + buildPhases = ( + 213FB36A17A21E59002EA528 /* Sources */, + 213FB36B17A21E59002EA528 /* Frameworks */, + 213FB36C17A21E59002EA528 /* Resources */, + 213FB36D17A21E59002EA528 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 213FB37517A21E59002EA528 /* PBXTargetDependency */, + ); + name = SAMLoadingViewTests; + productName = SAMLoadingViewTests; + productReference = 213FB36F17A21E59002EA528 /* SAMLoadingViewTests.octest */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 213FB34717A21E59002EA528 /* Project object */ = { + isa = PBXProject; + attributes = { + CLASSPREFIX = SAM; + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = "Sam Soffes"; + }; + buildConfigurationList = 213FB34A17A21E59002EA528 /* Build configuration list for PBXProject "SAMLoadingView" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 213FB34617A21E59002EA528; + productRefGroup = 213FB35017A21E59002EA528 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 213FB34E17A21E59002EA528 /* SAMLoadingView */, + 213FB36E17A21E59002EA528 /* SAMLoadingViewTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 213FB34D17A21E59002EA528 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 213FB39817A21EB7002EA528 /* Default-568h@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 213FB36C17A21E59002EA528 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 213FB36D17A21E59002EA528 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 213FB34B17A21E59002EA528 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 213FB38A17A21EB1002EA528 /* SAMLoadingView.m in Sources */, + 213FB39617A21EB7002EA528 /* SAMAppDelegate.m in Sources */, + 213FB39717A21EB7002EA528 /* main.m in Sources */, + 213FB3A517A221AA002EA528 /* SAMRootViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 213FB36A17A21E59002EA528 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 213FB38B17A21EB1002EA528 /* SAMLoadingView.m in Sources */, + 213FB3A217A21EBB002EA528 /* SAMLoadingViewTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 213FB37517A21E59002EA528 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 213FB34E17A21E59002EA528 /* SAMLoadingView */; + targetProxy = 213FB37417A21E59002EA528 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 213FB37F17A21E59002EA528 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + WARNING_CFLAGS = "-Weverything"; + }; + name = Debug; + }; + 213FB38017A21E59002EA528 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + WARNING_CFLAGS = "-Weverything"; + }; + name = Release; + }; + 213FB38217A21E59002EA528 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Example/Other Sources/SAMLoadingView-Prefix.pch"; + INFOPLIST_FILE = "Example/Resources/SAMLoadingView-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 213FB38317A21E59002EA528 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Example/Other Sources/SAMLoadingView-Prefix.pch"; + INFOPLIST_FILE = "Example/Resources/SAMLoadingView-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 213FB38517A21E59002EA528 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SAMLoadingView.app/SAMLoadingView"; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + INFOPLIST_FILE = "Tests/SAMLoadingViewTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 213FB38617A21E59002EA528 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SAMLoadingView.app/SAMLoadingView"; + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + INFOPLIST_FILE = "Tests/SAMLoadingViewTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 213FB34A17A21E59002EA528 /* Build configuration list for PBXProject "SAMLoadingView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 213FB37F17A21E59002EA528 /* Debug */, + 213FB38017A21E59002EA528 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 213FB38117A21E59002EA528 /* Build configuration list for PBXNativeTarget "SAMLoadingView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 213FB38217A21E59002EA528 /* Debug */, + 213FB38317A21E59002EA528 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 213FB38417A21E59002EA528 /* Build configuration list for PBXNativeTarget "SAMLoadingViewTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 213FB38517A21E59002EA528 /* Debug */, + 213FB38617A21E59002EA528 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 213FB34717A21E59002EA528 /* Project object */; +} diff --git a/SAMLoadingView/SAMLoadingView.h b/SAMLoadingView/SAMLoadingView.h new file mode 100644 index 0000000..99cbd20 --- /dev/null +++ b/SAMLoadingView/SAMLoadingView.h @@ -0,0 +1,29 @@ +// +// SAMLoadingView.h +// SAMLoadingView +// +// Created by Sam Soffes on 7/8/09. +// Copyright 2009-2011 Sam Soffes. All rights reserved. +// + +#import + +/** + An easy view to show loading similar to the loading screens in the iTunes or App Store applications. The view is + intended to cover another view while it is loading and the removed once loading is complete. + + This view will automatically center the text and the activity indicator. + */ +@interface SAMLoadingView : UIView + +/** + The text label that is displayed to the user. (read-only) + */ +@property (nonatomic, readonly) UILabel *textLabel; + +/** + A view that indicates loading activity to the user. (read-only) + */ +@property (nonatomic, readonly) UIActivityIndicatorView *activityIndicatorView; + +@end diff --git a/SAMLoadingView/SAMLoadingView.m b/SAMLoadingView/SAMLoadingView.m new file mode 100644 index 0000000..b5a5da4 --- /dev/null +++ b/SAMLoadingView/SAMLoadingView.m @@ -0,0 +1,104 @@ +// +// SAMLoadingView.m +// SAMLoadingView +// +// Created by Sam Soffes on 7/8/09. +// Copyright 2009-2011 Sam Soffes. All rights reserved. +// + +#import "SAMLoadingView.h" + +@implementation SAMLoadingView + +static CGFloat const kSAMLoadingViewInteriorPadding = 20.0f; +static CGFloat const kSAMLoadingViewIndicatorSize = 20.0f; +static CGFloat const kSAMLoadingViewIndicatorRightMargin = 8.0f; + +#pragma mark - Accessors + +@synthesize textLabel = _textLabel; +@synthesize activityIndicatorView = _activityIndicatorView; + +- (UILabel *)textLabel { + if (!_textLabel) { + _textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + _textLabel.text = @"Loading…"; + _textLabel.font = [UIFont systemFontOfSize:16.0f]; + _textLabel.textColor = [UIColor darkGrayColor]; + _textLabel.shadowColor = [UIColor whiteColor]; + _textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); + } + return _textLabel; +} + + +- (UIActivityIndicatorView *)activityIndicatorView { + if (!_activityIndicatorView) { + _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + _activityIndicatorView.hidesWhenStopped = NO; + [_activityIndicatorView startAnimating]; + } + return _activityIndicatorView; +} + + +#pragma mark - UIView + +- (id)initWithCoder:(NSCoder *)aDecoder { + if ((self = [super initWithCoder:aDecoder])) { + [self initialize]; + } + return self; +} + + +- (id)initWithFrame:(CGRect)frame { + if ((self = [super initWithFrame:frame])) { + [self initialize]; + } + return self; +} + + +- (void)drawRect:(CGRect)rect { + + CGRect frame = self.frame; + + // Calculate sizes + CGSize maxSize = CGSizeMake(frame.size.width - (kSAMLoadingViewInteriorPadding * 2.0f) - kSAMLoadingViewIndicatorSize - kSAMLoadingViewIndicatorRightMargin, + kSAMLoadingViewIndicatorSize); + + CGSize textSize = [self.textLabel.text sizeWithFont:self.textLabel.font constrainedToSize:maxSize + lineBreakMode:NSLineBreakByWordWrapping]; + + // Calculate position + CGFloat totalWidth = textSize.width + kSAMLoadingViewIndicatorSize + kSAMLoadingViewIndicatorRightMargin; + NSInteger y = (NSInteger)((frame.size.height / 2.0f) - (kSAMLoadingViewIndicatorSize / 2.0f)); + + // Position the indicator + self.activityIndicatorView.frame = CGRectMake((NSInteger)((frame.size.width - totalWidth) / 2.0f), y, kSAMLoadingViewIndicatorSize, + kSAMLoadingViewIndicatorSize); + + // Calculate text position + CGRect textRect = CGRectMake(self.activityIndicatorView.frame.origin.x + kSAMLoadingViewIndicatorSize + kSAMLoadingViewIndicatorRightMargin, y, + textSize.width, textSize.height); + + // Draw text + [self.textLabel drawTextInRect:textRect]; +} + + +#pragma mark - Private + +- (void)initialize { + // View defaults + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.backgroundColor = [UIColor whiteColor]; + self.opaque = YES; + self.contentMode = UIViewContentModeRedraw; + + // Setup the indicator + [self addSubview:self.activityIndicatorView]; +} + +@end diff --git a/Tests/SAMLoadingViewTests-Info.plist b/Tests/SAMLoadingViewTests-Info.plist new file mode 100644 index 0000000..6b8a339 --- /dev/null +++ b/Tests/SAMLoadingViewTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.samsoffes.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Tests/SAMLoadingViewTests.m b/Tests/SAMLoadingViewTests.m new file mode 100644 index 0000000..d615866 --- /dev/null +++ b/Tests/SAMLoadingViewTests.m @@ -0,0 +1,24 @@ +// +// SAMLoadingViewTests.m +// SAMLoadingViewTests +// +// Created by Sam Soffes on 7/25/13. +// Copyright (c) 2013 Sam Soffes. All rights reserved. +// + +#import +#import "SAMLoadingView.h" + +@interface SAMLoadingViewTests : SenTestCase +@end + +@implementation SAMLoadingViewTests + +- (void)testActivityIndicator { + SAMLoadingView *loadingView = [[SAMLoadingView alloc] init]; + + // Make sure it's loading when you initialize it + STAssertTrue([loadingView.activityIndicatorView isAnimating], nil); +} + +@end