From 06506e7392f9df73f78752dc791517b4fff4f7f7 Mon Sep 17 00:00:00 2001 From: Grigory Lutkov Date: Thu, 12 Nov 2015 18:09:41 +0300 Subject: [PATCH] Added Carthage support, updated to NS_ENUM, updated demo project --- .../project.pbxproj | 89 ++--- .../contents.xcworkspacedata | 10 - Demo/LGPlaceholderViewDemo/AppDelegate.h | 2 - Demo/LGPlaceholderViewDemo/AppDelegate.m | 11 +- Demo/LGPlaceholderViewDemo/Info.plist | 2 +- .../NavigationController.m | 30 +- .../TableViewController.m | 8 +- Demo/Podfile | 9 - Demo/Podfile.lock | 14 - Demo/podsInstall.command | 5 - Demo/podsUpdate.command | 5 - .../project.pbxproj | 304 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../LGPlaceholderViewFramework.xcscheme | 80 +++++ .../LGPlaceholderViewFramework/Info.plist | 26 ++ .../LGPlaceholderViewFramework.h | 19 ++ LGPlaceholderView.podspec | 2 +- LGPlaceholderView/LGPlaceholderView.m | 269 ++++++++-------- README.md | 14 +- 19 files changed, 631 insertions(+), 275 deletions(-) delete mode 100644 Demo/LGPlaceholderViewDemo.xcworkspace/contents.xcworkspacedata delete mode 100644 Demo/Podfile delete mode 100644 Demo/Podfile.lock delete mode 100644 Demo/podsInstall.command delete mode 100644 Demo/podsUpdate.command create mode 100644 Framework/LGPlaceholderViewFramework.xcodeproj/project.pbxproj create mode 100644 Framework/LGPlaceholderViewFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Framework/LGPlaceholderViewFramework.xcodeproj/xcshareddata/xcschemes/LGPlaceholderViewFramework.xcscheme create mode 100644 Framework/LGPlaceholderViewFramework/Info.plist create mode 100644 Framework/LGPlaceholderViewFramework/LGPlaceholderViewFramework.h diff --git a/Demo/LGPlaceholderViewDemo.xcodeproj/project.pbxproj b/Demo/LGPlaceholderViewDemo.xcodeproj/project.pbxproj index 177f661..1331d87 100644 --- a/Demo/LGPlaceholderViewDemo.xcodeproj/project.pbxproj +++ b/Demo/LGPlaceholderViewDemo.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 4A41726A1A9B810000D17B93 /* PlaceholderScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4172691A9B810000D17B93 /* PlaceholderScrollViewController.m */; }; + 4A836B661BF4E023008374ED /* LGPlaceholderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A836B651BF4E023008374ED /* LGPlaceholderView.m */; }; 4A890BE01A9A191200843850 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A890BDF1A9A191200843850 /* main.m */; }; 4A890BE31A9A191200843850 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A890BE21A9A191200843850 /* AppDelegate.m */; }; 4A890BEB1A9A191300843850 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A890BEA1A9A191300843850 /* Images.xcassets */; }; @@ -17,12 +18,13 @@ 4ABB0E471A9E370F009E5135 /* PlaceholderTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ABB0E461A9E370F009E5135 /* PlaceholderTableViewController.m */; }; 4ABB0E4A1A9E4DEE009E5135 /* PlaceholderCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ABB0E491A9E4DEE009E5135 /* PlaceholderCollectionViewController.m */; }; 4ABB0E4D1A9E4F69009E5135 /* PlaceholderWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ABB0E4C1A9E4F69009E5135 /* PlaceholderWebViewController.m */; }; - A2ABF2001ACBA006146C44C2 /* libPods-LGPlaceholderViewDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D121CA33D600439D4A06B885 /* libPods-LGPlaceholderViewDemo.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 4A4172681A9B810000D17B93 /* PlaceholderScrollViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderScrollViewController.h; sourceTree = ""; }; 4A4172691A9B810000D17B93 /* PlaceholderScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaceholderScrollViewController.m; sourceTree = ""; }; + 4A836B641BF4E023008374ED /* LGPlaceholderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGPlaceholderView.h; sourceTree = ""; }; + 4A836B651BF4E023008374ED /* LGPlaceholderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGPlaceholderView.m; sourceTree = ""; }; 4A890BDA1A9A191200843850 /* LGPlaceholderViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LGPlaceholderViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4A890BDE1A9A191200843850 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4A890BDF1A9A191200843850 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -41,9 +43,6 @@ 4ABB0E491A9E4DEE009E5135 /* PlaceholderCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaceholderCollectionViewController.m; sourceTree = ""; }; 4ABB0E4B1A9E4F69009E5135 /* PlaceholderWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderWebViewController.h; sourceTree = ""; }; 4ABB0E4C1A9E4F69009E5135 /* PlaceholderWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaceholderWebViewController.m; sourceTree = ""; }; - 57D82F8A0498C171BA56127A /* Pods-LGPlaceholderViewDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LGPlaceholderViewDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-LGPlaceholderViewDemo/Pods-LGPlaceholderViewDemo.release.xcconfig"; sourceTree = ""; }; - B9E5B88AEE72DB88D1D09904 /* Pods-LGPlaceholderViewDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LGPlaceholderViewDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LGPlaceholderViewDemo/Pods-LGPlaceholderViewDemo.debug.xcconfig"; sourceTree = ""; }; - D121CA33D600439D4A06B885 /* libPods-LGPlaceholderViewDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-LGPlaceholderViewDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,7 +50,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - A2ABF2001ACBA006146C44C2 /* libPods-LGPlaceholderViewDemo.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -61,7 +59,6 @@ 2170087D6B51C392851FD89E /* Frameworks */ = { isa = PBXGroup; children = ( - D121CA33D600439D4A06B885 /* libPods-LGPlaceholderViewDemo.a */, ); name = Frameworks; sourceTree = ""; @@ -78,12 +75,22 @@ name = "Demo View Controllers"; sourceTree = ""; }; + 4A836B631BF4E023008374ED /* LGPlaceholderView */ = { + isa = PBXGroup; + children = ( + 4A836B641BF4E023008374ED /* LGPlaceholderView.h */, + 4A836B651BF4E023008374ED /* LGPlaceholderView.m */, + ); + name = LGPlaceholderView; + path = ../LGPlaceholderView; + sourceTree = ""; + }; 4A890BD11A9A191200843850 = { isa = PBXGroup; children = ( + 4A836B631BF4E023008374ED /* LGPlaceholderView */, 4A890BDC1A9A191200843850 /* LGPlaceholderViewDemo */, 4A890BDB1A9A191200843850 /* Products */, - C6044416B6BE22555E1C75D6 /* Pods */, 2170087D6B51C392851FD89E /* Frameworks */, ); sourceTree = ""; @@ -166,15 +173,6 @@ name = "UIWebView + Loading"; sourceTree = ""; }; - C6044416B6BE22555E1C75D6 /* Pods */ = { - isa = PBXGroup; - children = ( - B9E5B88AEE72DB88D1D09904 /* Pods-LGPlaceholderViewDemo.debug.xcconfig */, - 57D82F8A0498C171BA56127A /* Pods-LGPlaceholderViewDemo.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -182,12 +180,9 @@ isa = PBXNativeTarget; buildConfigurationList = 4A890BFD1A9A191300843850 /* Build configuration list for PBXNativeTarget "LGPlaceholderViewDemo" */; buildPhases = ( - 4517D1983152AB3702F9E85D /* Check Pods Manifest.lock */, 4A890BD61A9A191200843850 /* Sources */, 4A890BD71A9A191200843850 /* Frameworks */, 4A890BD81A9A191200843850 /* Resources */, - 08E45A5C7A621F2E56AD6E0A /* Copy Pods Resources */, - 3737ED2E6CD294FDBA96741E /* Embed Pods Frameworks */, ); buildRules = ( ); @@ -204,7 +199,7 @@ 4A890BD21A9A191200843850 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0610; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = test; TargetAttributes = { 4A890BD91A9A191200843850 = { @@ -241,54 +236,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 08E45A5C7A621F2E56AD6E0A /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LGPlaceholderViewDemo/Pods-LGPlaceholderViewDemo-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 3737ED2E6CD294FDBA96741E /* Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LGPlaceholderViewDemo/Pods-LGPlaceholderViewDemo-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 4517D1983152AB3702F9E85D /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 4A890BD61A9A191200843850 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -297,6 +244,7 @@ 4A890C071A9A1A7700843850 /* NavigationController.m in Sources */, 4ABB0E471A9E370F009E5135 /* PlaceholderTableViewController.m in Sources */, 4A41726A1A9B810000D17B93 /* PlaceholderScrollViewController.m in Sources */, + 4A836B661BF4E023008374ED /* LGPlaceholderView.m in Sources */, 4ABB0E4D1A9E4F69009E5135 /* PlaceholderWebViewController.m in Sources */, 4A890BE31A9A191200843850 /* AppDelegate.m in Sources */, 4ABB0E4A1A9E4DEE009E5135 /* PlaceholderCollectionViewController.m in Sources */, @@ -329,6 +277,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -389,7 +338,6 @@ }; 4A890BFE1A9A191300843850 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B9E5B88AEE72DB88D1D09904 /* Pods-LGPlaceholderViewDemo.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -398,13 +346,13 @@ INFOPLIST_FILE = LGPlaceholderViewDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; 4A890BFF1A9A191300843850 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 57D82F8A0498C171BA56127A /* Pods-LGPlaceholderViewDemo.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -413,6 +361,7 @@ INFOPLIST_FILE = LGPlaceholderViewDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/Demo/LGPlaceholderViewDemo.xcworkspace/contents.xcworkspacedata b/Demo/LGPlaceholderViewDemo.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 5c46639..0000000 --- a/Demo/LGPlaceholderViewDemo.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/Demo/LGPlaceholderViewDemo/AppDelegate.h b/Demo/LGPlaceholderViewDemo/AppDelegate.h index 4696875..8ec6b2a 100644 --- a/Demo/LGPlaceholderViewDemo/AppDelegate.h +++ b/Demo/LGPlaceholderViewDemo/AppDelegate.h @@ -7,11 +7,9 @@ // #import -#import "NavigationController.h" @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (strong, nonatomic) UINavigationController *navigationController; @end diff --git a/Demo/LGPlaceholderViewDemo/AppDelegate.m b/Demo/LGPlaceholderViewDemo/AppDelegate.m index 139cd90..fe373f8 100644 --- a/Demo/LGPlaceholderViewDemo/AppDelegate.m +++ b/Demo/LGPlaceholderViewDemo/AppDelegate.m @@ -7,18 +7,21 @@ // #import "AppDelegate.h" +#import "NavigationController.h" +#import "TableViewController.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.navigationController = [NavigationController new]; - + TableViewController *tableViewController = [TableViewController new]; + NavigationController *navigationController = [[NavigationController alloc] initWithRootViewController:tableViewController]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.rootViewController = self.navigationController; + self.window.rootViewController = navigationController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; - + return YES; } diff --git a/Demo/LGPlaceholderViewDemo/Info.plist b/Demo/LGPlaceholderViewDemo/Info.plist index 493646a..7c961f8 100644 --- a/Demo/LGPlaceholderViewDemo/Info.plist +++ b/Demo/LGPlaceholderViewDemo/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.test.$(PRODUCT_NAME) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Demo/LGPlaceholderViewDemo/NavigationController.m b/Demo/LGPlaceholderViewDemo/NavigationController.m index 156d507..0eacca0 100644 --- a/Demo/LGPlaceholderViewDemo/NavigationController.m +++ b/Demo/LGPlaceholderViewDemo/NavigationController.m @@ -7,30 +7,36 @@ // #import "NavigationController.h" -#import "TableViewController.h" @interface NavigationController () -@property (strong, nonatomic) TableViewController *tableViewController; - @end @implementation NavigationController -- (id)init +- (void)viewDidLoad { - self = [super init]; - if (self) - { - self.tableViewController = [TableViewController new]; - [self setViewControllers:@[self.tableViewController]]; - } - return self; + [super viewDidLoad]; + + self.navigationBar.translucent = YES; + self.navigationBar.barTintColor = [UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f]; + self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]}; + self.navigationBar.tintColor = [UIColor colorWithWhite:1.f alpha:0.5]; } - (BOOL)shouldAutorotate { - return self.topViewController.shouldAutorotate; + return YES; +} + +- (BOOL)prefersStatusBarHidden +{ + return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); +} + +- (UIStatusBarStyle)preferredStatusBarStyle +{ + return UIStatusBarStyleLightContent; } @end diff --git a/Demo/LGPlaceholderViewDemo/TableViewController.m b/Demo/LGPlaceholderViewDemo/TableViewController.m index a1a027a..967624b 100644 --- a/Demo/LGPlaceholderViewDemo/TableViewController.m +++ b/Demo/LGPlaceholderViewDemo/TableViewController.m @@ -27,13 +27,13 @@ - (id)init if (self) { self.title = @"LGPlaceholderView"; - + _titlesArray = @[@"UIView + All Types", @"UIScrollView + Loading", @"UITableView + Loading", @"UICollectionView + Loading", @"UIWebView + Loading"]; - + [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; } return self; @@ -56,10 +56,10 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; - + cell.textLabel.font = [UIFont systemFontOfSize:16.f]; cell.textLabel.text = _titlesArray[indexPath.row]; - + return cell; } diff --git a/Demo/Podfile b/Demo/Podfile deleted file mode 100644 index 6c05ef4..0000000 --- a/Demo/Podfile +++ /dev/null @@ -1,9 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' - -platform :ios, '6.0' - -xcodeproj 'LGPlaceholderViewDemo' - -target 'LGPlaceholderViewDemo' do - pod 'LGPlaceholderView', :path => '../' -end diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock deleted file mode 100644 index 70bfb79..0000000 --- a/Demo/Podfile.lock +++ /dev/null @@ -1,14 +0,0 @@ -PODS: - - LGPlaceholderView (1.0.1) - -DEPENDENCIES: - - LGPlaceholderView (from `../`) - -EXTERNAL SOURCES: - LGPlaceholderView: - :path: ../ - -SPEC CHECKSUMS: - LGPlaceholderView: 3e999b0b0d3dae2382fef5bb3d233ad76a2fd7a6 - -COCOAPODS: 0.39.0 diff --git a/Demo/podsInstall.command b/Demo/podsInstall.command deleted file mode 100644 index 3c76888..0000000 --- a/Demo/podsInstall.command +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cd "$(dirname "$0")" - -pod install diff --git a/Demo/podsUpdate.command b/Demo/podsUpdate.command deleted file mode 100644 index f48a821..0000000 --- a/Demo/podsUpdate.command +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cd "$(dirname "$0")" - -pod update diff --git a/Framework/LGPlaceholderViewFramework.xcodeproj/project.pbxproj b/Framework/LGPlaceholderViewFramework.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8b4c41b --- /dev/null +++ b/Framework/LGPlaceholderViewFramework.xcodeproj/project.pbxproj @@ -0,0 +1,304 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4A836B6A1BF4E229008374ED /* LGPlaceholderView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A836B681BF4E229008374ED /* LGPlaceholderView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4A836B6B1BF4E229008374ED /* LGPlaceholderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A836B691BF4E229008374ED /* LGPlaceholderView.m */; }; + 4AF1395B1BF3846F0037B073 /* LGPlaceholderViewFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 4AF1395A1BF3846F0037B073 /* LGPlaceholderViewFramework.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 4A836B681BF4E229008374ED /* LGPlaceholderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LGPlaceholderView.h; sourceTree = ""; }; + 4A836B691BF4E229008374ED /* LGPlaceholderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LGPlaceholderView.m; sourceTree = ""; }; + 4AF139571BF3846F0037B073 /* LGPlaceholderViewFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LGPlaceholderViewFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4AF1395A1BF3846F0037B073 /* LGPlaceholderViewFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LGPlaceholderViewFramework.h; sourceTree = ""; }; + 4AF1395C1BF3846F0037B073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4AF139531BF3846F0037B073 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4A836B671BF4E229008374ED /* LGPlaceholderView */ = { + isa = PBXGroup; + children = ( + 4A836B681BF4E229008374ED /* LGPlaceholderView.h */, + 4A836B691BF4E229008374ED /* LGPlaceholderView.m */, + ); + name = LGPlaceholderView; + path = ../LGPlaceholderView; + sourceTree = ""; + }; + 4AF1394D1BF3846F0037B073 = { + isa = PBXGroup; + children = ( + 4A836B671BF4E229008374ED /* LGPlaceholderView */, + 4AF139591BF3846F0037B073 /* LGPlaceholderViewFramework */, + 4AF139581BF3846F0037B073 /* Products */, + ); + sourceTree = ""; + }; + 4AF139581BF3846F0037B073 /* Products */ = { + isa = PBXGroup; + children = ( + 4AF139571BF3846F0037B073 /* LGPlaceholderViewFramework.framework */, + ); + name = Products; + sourceTree = ""; + }; + 4AF139591BF3846F0037B073 /* LGPlaceholderViewFramework */ = { + isa = PBXGroup; + children = ( + 4AF1395A1BF3846F0037B073 /* LGPlaceholderViewFramework.h */, + 4AF1395C1BF3846F0037B073 /* Info.plist */, + ); + path = LGPlaceholderViewFramework; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 4AF139541BF3846F0037B073 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 4A836B6A1BF4E229008374ED /* LGPlaceholderView.h in Headers */, + 4AF1395B1BF3846F0037B073 /* LGPlaceholderViewFramework.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 4AF139561BF3846F0037B073 /* LGPlaceholderViewFramework */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4AF1395F1BF3846F0037B073 /* Build configuration list for PBXNativeTarget "LGPlaceholderViewFramework" */; + buildPhases = ( + 4AF139521BF3846F0037B073 /* Sources */, + 4AF139531BF3846F0037B073 /* Frameworks */, + 4AF139541BF3846F0037B073 /* Headers */, + 4AF139551BF3846F0037B073 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = LGPlaceholderViewFramework; + productName = LGPlaceholderViewFramework; + productReference = 4AF139571BF3846F0037B073 /* LGPlaceholderViewFramework.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4AF1394E1BF3846F0037B073 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0710; + ORGANIZATIONNAME = "Grigory Lutkov"; + TargetAttributes = { + 4AF139561BF3846F0037B073 = { + CreatedOnToolsVersion = 7.1.1; + }; + }; + }; + buildConfigurationList = 4AF139511BF3846F0037B073 /* Build configuration list for PBXProject "LGPlaceholderViewFramework" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4AF1394D1BF3846F0037B073; + productRefGroup = 4AF139581BF3846F0037B073 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4AF139561BF3846F0037B073 /* LGPlaceholderViewFramework */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 4AF139551BF3846F0037B073 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4AF139521BF3846F0037B073 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4A836B6B1BF4E229008374ED /* LGPlaceholderView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4AF1395D1BF3846F0037B073 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 4AF1395E1BF3846F0037B073 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 4AF139601BF3846F0037B073 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = LGPlaceholderViewFramework/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.Friend-LGA.LGPlaceholderViewFramework"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 4AF139611BF3846F0037B073 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = LGPlaceholderViewFramework/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.Friend-LGA.LGPlaceholderViewFramework"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4AF139511BF3846F0037B073 /* Build configuration list for PBXProject "LGPlaceholderViewFramework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4AF1395D1BF3846F0037B073 /* Debug */, + 4AF1395E1BF3846F0037B073 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4AF1395F1BF3846F0037B073 /* Build configuration list for PBXNativeTarget "LGPlaceholderViewFramework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4AF139601BF3846F0037B073 /* Debug */, + 4AF139611BF3846F0037B073 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4AF1394E1BF3846F0037B073 /* Project object */; +} diff --git a/Framework/LGPlaceholderViewFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Framework/LGPlaceholderViewFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b78b8d9 --- /dev/null +++ b/Framework/LGPlaceholderViewFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Framework/LGPlaceholderViewFramework.xcodeproj/xcshareddata/xcschemes/LGPlaceholderViewFramework.xcscheme b/Framework/LGPlaceholderViewFramework.xcodeproj/xcshareddata/xcschemes/LGPlaceholderViewFramework.xcscheme new file mode 100644 index 0000000..b81a162 --- /dev/null +++ b/Framework/LGPlaceholderViewFramework.xcodeproj/xcshareddata/xcschemes/LGPlaceholderViewFramework.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Framework/LGPlaceholderViewFramework/Info.plist b/Framework/LGPlaceholderViewFramework/Info.plist new file mode 100644 index 0000000..d3de8ee --- /dev/null +++ b/Framework/LGPlaceholderViewFramework/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Framework/LGPlaceholderViewFramework/LGPlaceholderViewFramework.h b/Framework/LGPlaceholderViewFramework/LGPlaceholderViewFramework.h new file mode 100644 index 0000000..2bd5bde --- /dev/null +++ b/Framework/LGPlaceholderViewFramework/LGPlaceholderViewFramework.h @@ -0,0 +1,19 @@ +// +// LGPlaceholderViewFramework.h +// LGPlaceholderViewFramework +// +// Created by Grigory Lutkov on 11.11.15. +// Copyright © 2015 Grigory Lutkov. All rights reserved. +// + +#import + +//! Project version number for LGPlaceholderViewFramework. +FOUNDATION_EXPORT double LGPlaceholderViewFrameworkVersionNumber; + +//! Project version string for LGPlaceholderViewFramework. +FOUNDATION_EXPORT const unsigned char LGPlaceholderViewFrameworkVersionString[]; + +#pragma mark - + +#import diff --git a/LGPlaceholderView.podspec b/LGPlaceholderView.podspec index 9f6a4ed..9bec598 100644 --- a/LGPlaceholderView.podspec +++ b/LGPlaceholderView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlaceholderView' - s.version = '1.0.1' + s.version = '1.0.2' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlaceholderView' diff --git a/LGPlaceholderView/LGPlaceholderView.m b/LGPlaceholderView/LGPlaceholderView.m index b52145b..aefbaf6 100644 --- a/LGPlaceholderView/LGPlaceholderView.m +++ b/LGPlaceholderView/LGPlaceholderView.m @@ -34,7 +34,7 @@ @interface LGPlaceholderView () -typedef enum +typedef NS_ENUM(NSUInteger, LGPlaceholderViewType) { LGPlaceholderViewTypeText = 0, LGPlaceholderViewTypeActivityIndicator = 1, @@ -42,8 +42,7 @@ @interface LGPlaceholderView () LGPlaceholderViewTypeProgressView = 3, LGPlaceholderViewTypeProgressViewAndText = 4, LGPlaceholderViewTypeInnerView = 5 -} -LGPlaceholderViewType; +}; @property (assign, nonatomic, getter=isObserversAdded) BOOL observersAdded; @@ -76,26 +75,26 @@ - (instancetype)initWithView:(UIView *)view if (self) { _parentView = view; - + _tintColor = [UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f]; _font = [UIFont systemFontOfSize:18.f]; _textAlignment = NSTextAlignmentCenter; _progressText = kProgressTextDefault; _contentInset = UIEdgeInsetsMake(20.f, 20.f, 20.f, 20.f); - + [super setBackgroundColor:[UIColor clearColor]]; - + self.clipsToBounds = NO; self.layer.zPosition = FLT_MAX; - + _backgroundView = [UIView new]; _backgroundView.alpha = 0.f; - + if (![_parentView.backgroundColor isEqual:[UIColor clearColor]]) _backgroundView.backgroundColor = [_parentView.backgroundColor colorWithAlphaComponent:1.f]; else _backgroundView.backgroundColor = [UIColor whiteColor]; - + [self addSubview:_backgroundView]; } return self; @@ -120,7 +119,7 @@ - (void)dealloc - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; - + if (!newSuperview) [self removeObservers]; else @@ -134,7 +133,7 @@ - (void)setContentInset:(UIEdgeInsets)contentInset if (!UIEdgeInsetsEqualToEdgeInsets(_contentInset, contentInset)) { _contentInset = contentInset; - + [self layoutInvalidate]; } } @@ -142,7 +141,7 @@ - (void)setContentInset:(UIEdgeInsets)contentInset - (void)setTintColor:(UIColor *)tintColor { _tintColor = tintColor; - + if (_activityIndicator) _activityIndicator.color = _tintColor; if (_progressView) _progressView.tintColor = _tintColor; if (_progressLabel) _progressLabel.textColor = _tintColor; @@ -158,31 +157,31 @@ - (void)setBackgroundColor:(UIColor *)backgroundColor - (void)setProgressValue:(float)progressValue animated:(BOOL)animated { _progressValue = progressValue; - + if (_progressView) [_progressView setProgress:_progressValue animated:animated]; } - (void)setProgressText:(NSString *)progressText animated:(BOOL)animated { _progressText = progressText; - + if (_progressLabel) { _progressLabel.text = _progressText; - + CGSize progressLabelSize = [_progressLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; - + CGFloat progressLabelOriginX = _wrapperView.frame.size.width/2-progressLabelSize.width/2; if (_progressLabel.textAlignment == NSTextAlignmentLeft) progressLabelOriginX = 0.f; else if (_progressLabel.textAlignment == NSTextAlignmentRight) progressLabelOriginX = _wrapperView.frame.size.width-progressLabelSize.width; - + CGRect progressLabelFrame = CGRectMake(progressLabelOriginX, _progressView.frame.origin.y+_progressView.frame.size.height+kDistantBetweenComponents, progressLabelSize.width, progressLabelSize.height); if ([UIScreen mainScreen].scale == 1.f) progressLabelFrame = CGRectIntegral(progressLabelFrame); _progressLabel.frame = progressLabelFrame; - + if (animated) [UIView transitionWithView:_progressLabel duration:0.2 @@ -195,46 +194,46 @@ - (void)setProgressText:(NSString *)progressText animated:(BOOL)animated - (void)setFont:(UIFont *)font { _font = font; - + BOOL isChanged = NO; - + if (_textLabel) { _textLabel.font = _font; - + isChanged = YES; } - + if (_progressLabel) { _progressLabel.font = _font; - + isChanged = YES; } - + if (isChanged) [self layoutInvalidate]; } - (void)setTextAlignment:(NSTextAlignment)textAlignment { _textAlignment = textAlignment; - + BOOL isChanged = NO; - + if (_textLabel) { _textLabel.textAlignment = _textAlignment; - + isChanged = YES; } - + if (_progressLabel) { _progressLabel.textAlignment = _textAlignment; - + isChanged = YES; } - + if (isChanged) [self layoutInvalidate]; } @@ -246,25 +245,25 @@ - (void)layoutInvalidate { UIEdgeInsets parentInset = UIEdgeInsetsZero; CGPoint selfOffset = CGPointZero; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { UIScrollView *parentScrollView = (UIScrollView *)_parentView; - + parentInset = parentScrollView.contentInset; CGPoint parentOffset = parentScrollView.contentOffset; - + if (parentOffset.y >= -parentInset.top) selfOffset.y = parentOffset.y+parentInset.top; - + if (parentOffset.x >= -parentInset.left) selfOffset.x = parentOffset.x+parentInset.left; - + if (parentScrollView.contentSize.height > parentScrollView.frame.size.height-parentInset.top-parentInset.bottom) { if (parentOffset.y > parentScrollView.contentSize.height-parentScrollView.frame.size.height+parentInset.bottom) selfOffset.y = parentScrollView.contentSize.height-self.frame.size.height; } else selfOffset.y = 0.f; - + if (parentScrollView.contentSize.width > parentScrollView.frame.size.width-parentInset.left-parentInset.right) { if (parentOffset.x > parentScrollView.contentSize.width-parentScrollView.frame.size.width+parentInset.right) @@ -272,35 +271,35 @@ - (void)layoutInvalidate } else selfOffset.x = 0.f; } - + // ----- - + CGRect selfFrame = CGRectMake(selfOffset.x, selfOffset.y, _parentView.frame.size.width-parentInset.left-parentInset.right, _parentView.frame.size.height-parentInset.top-parentInset.bottom); if ([UIScreen mainScreen].scale == 1.f) selfFrame = CGRectIntegral(selfFrame); self.frame = selfFrame; - + _backgroundView.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height); - + // ----- - + CGSize wrapperSize = CGSizeMake(self.frame.size.width-_contentInset.left-_contentInset.right, self.frame.size.height-_contentInset.top-_contentInset.bottom); CGRect wrapperFrame = CGRectMake(_contentInset.left, _contentInset.top, wrapperSize.width, wrapperSize.height); if ([UIScreen mainScreen].scale == 1.f) wrapperFrame = CGRectIntegral(wrapperFrame); - + if (_savedWrapperView) _savedWrapperView.frame = wrapperFrame; - + _wrapperView.frame = wrapperFrame; - + // ----- - + if (_type == LGPlaceholderViewTypeText) { CGSize textLabelSize = [_textLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; - + CGFloat textLabelOriginX = _wrapperView.frame.size.width/2-textLabelSize.width/2; if (_textLabel.textAlignment == NSTextAlignmentLeft) textLabelOriginX = 0.f; else if (_textLabel.textAlignment == NSTextAlignmentRight) textLabelOriginX = _wrapperView.frame.size.width-textLabelSize.width; - + CGRect textLabelFrame = CGRectMake(textLabelOriginX, _wrapperView.frame.size.height/2-textLabelSize.height/2, textLabelSize.width, @@ -320,20 +319,20 @@ - (void)layoutInvalidate else if (_type == LGPlaceholderViewTypeActivityIndicatorAndText) { CGSize textLabelSize = [_textLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; - + CGFloat commonHeight = textLabelSize.height+kDistantBetweenComponents+_activityIndicator.frame.size.height; - + CGFloat textLabelOriginX = _wrapperView.frame.size.width/2-textLabelSize.width/2; if (_textLabel.textAlignment == NSTextAlignmentLeft) textLabelOriginX = 0.f; else if (_textLabel.textAlignment == NSTextAlignmentRight) textLabelOriginX = _wrapperView.frame.size.width-textLabelSize.width; - + CGRect textLabelFrame = CGRectMake(textLabelOriginX, _wrapperView.frame.size.height/2-commonHeight/2, textLabelSize.width, textLabelSize.height); if ([UIScreen mainScreen].scale == 1.f) textLabelFrame = CGRectIntegral(textLabelFrame); _textLabel.frame = textLabelFrame; - + CGRect activityIndicatorFrame = CGRectMake(_wrapperView.frame.size.width/2-_activityIndicator.frame.size.width/2, _textLabel.frame.origin.y+_textLabel.frame.size.height+kDistantBetweenComponents, _activityIndicator.frame.size.width, @@ -344,20 +343,20 @@ - (void)layoutInvalidate else if (_type == LGPlaceholderViewTypeProgressView) { CGSize progressLabelSize = [_progressLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; - + CGFloat commonHeight = _progressView.frame.size.height+kDistantBetweenComponents+progressLabelSize.height; - + CGRect progressViewFrame = CGRectMake(0.f, _wrapperView.frame.size.height/2-commonHeight/2, _wrapperView.frame.size.width, _progressView.frame.size.height); if ([UIScreen mainScreen].scale == 1.f) progressViewFrame = CGRectIntegral(progressViewFrame); _progressView.frame = progressViewFrame; - + CGFloat progressLabelOriginX = _wrapperView.frame.size.width/2-progressLabelSize.width/2; if (_progressLabel.textAlignment == NSTextAlignmentLeft) progressLabelOriginX = 0.f; else if (_progressLabel.textAlignment == NSTextAlignmentRight) progressLabelOriginX = _wrapperView.frame.size.width-progressLabelSize.width; - + CGRect progressLabelFrame = CGRectMake(progressLabelOriginX, _progressView.frame.origin.y+_progressView.frame.size.height+kDistantBetweenComponents, progressLabelSize.width, @@ -369,31 +368,31 @@ - (void)layoutInvalidate { CGSize textLabelSize = [_textLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; CGSize progressLabelSize = [_progressLabel sizeThatFits:CGSizeMake(_wrapperView.frame.size.width, CGFLOAT_MAX)]; - + CGFloat commonHeight = textLabelSize.height+kDistantBetweenComponents+_progressView.frame.size.height+kDistantBetweenComponents+progressLabelSize.height; - + CGFloat textLabelOriginX = _wrapperView.frame.size.width/2-textLabelSize.width/2; if (_textLabel.textAlignment == NSTextAlignmentLeft) textLabelOriginX = 0.f; else if (_textLabel.textAlignment == NSTextAlignmentRight) textLabelOriginX = _wrapperView.frame.size.width-textLabelSize.width; - + CGRect textLabelFrame = CGRectMake(textLabelOriginX, _wrapperView.frame.size.height/2-commonHeight/2, textLabelSize.width, textLabelSize.height); if ([UIScreen mainScreen].scale == 1.f) textLabelFrame = CGRectIntegral(textLabelFrame); _textLabel.frame = textLabelFrame; - + CGRect progressViewFrame = CGRectMake(0.f, _textLabel.frame.origin.y+_textLabel.frame.size.height+kDistantBetweenComponents, _wrapperView.frame.size.width, _progressView.frame.size.height); if ([UIScreen mainScreen].scale == 1.f) progressViewFrame = CGRectIntegral(progressViewFrame); _progressView.frame = progressViewFrame; - + CGFloat progressLabelOriginX = _wrapperView.frame.size.width/2-progressLabelSize.width/2; if (_progressLabel.textAlignment == NSTextAlignmentLeft) progressLabelOriginX = 0.f; else if (_progressLabel.textAlignment == NSTextAlignmentRight) progressLabelOriginX = _wrapperView.frame.size.width-progressLabelSize.width; - + CGRect progressLabelFrame = CGRectMake(progressLabelOriginX, _progressView.frame.origin.y+_progressView.frame.size.height+kDistantBetweenComponents, progressLabelSize.width, @@ -419,25 +418,25 @@ - (void)updatePosition { UIEdgeInsets parentInset = UIEdgeInsetsZero; CGPoint selfOffset = CGPointZero; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { UIScrollView *parentScrollView = (UIScrollView *)_parentView; - + parentInset = parentScrollView.contentInset; CGPoint parentOffset = parentScrollView.contentOffset; - + if (parentOffset.y >= -parentInset.top) selfOffset.y = parentOffset.y+parentInset.top; - + if (parentOffset.x >= -parentInset.left) selfOffset.x = parentOffset.x+parentInset.left; - + if (parentScrollView.contentSize.height > parentScrollView.frame.size.height-parentInset.top-parentInset.bottom) { if (parentOffset.y > parentScrollView.contentSize.height-parentScrollView.frame.size.height+parentInset.bottom) selfOffset.y = parentScrollView.contentSize.height-self.frame.size.height; } else selfOffset.y = 0.f; - + if (parentScrollView.contentSize.width > parentScrollView.frame.size.width-parentInset.left-parentInset.right) { if (parentOffset.x > parentScrollView.contentSize.width-parentScrollView.frame.size.width+parentInset.right) @@ -445,9 +444,9 @@ - (void)updatePosition } else selfOffset.x = 0.f; } - + // ----- - + CGRect selfFrame = CGRectMake(selfOffset.x, selfOffset.y, _parentView.frame.size.width-parentInset.left-parentInset.right, _parentView.frame.size.height-parentInset.top-parentInset.bottom); if ([UIScreen mainScreen].scale == 1.f) selfFrame = CGRectIntegral(selfFrame); self.center = CGPointMake(selfFrame.origin.x+selfFrame.size.width/2, selfFrame.origin.y+selfFrame.size.height/2); @@ -459,20 +458,20 @@ - (void)saveWrapperViewImageIfNeeded if (_wrapperView) { UIImage *image = [LGPlaceholderView screenshotMakeOfView:_wrapperView inPixels:NO]; - + _savedWrapperView = [[UIImageView alloc] initWithImage:image]; _savedWrapperView.contentMode = UIViewContentModeCenter; [self addSubview:_savedWrapperView]; } - + // ----- - + [self removeSubviews]; - + [self restoreDefaults]; - + // ----- - + _wrapperView = [UIView new]; _wrapperView.alpha = 0.f; _wrapperView.backgroundColor = [UIColor clearColor]; @@ -487,31 +486,31 @@ - (void)removeSubviews [_activityIndicator removeFromSuperview]; self.activityIndicator = nil; } - + if (_progressView) { [_progressView removeFromSuperview]; self.progressView = nil; } - + if (_progressLabel) { [_progressLabel removeFromSuperview]; self.progressLabel = nil; } - + if (_textLabel) { [_textLabel removeFromSuperview]; self.textLabel = nil; } - + if (_innerView) { [_innerView removeFromSuperview]; self.innerView = nil; } - + [_wrapperView removeFromSuperview]; self.wrapperView = nil; } @@ -532,7 +531,7 @@ - (UILabel *)makeLabelWithText:(NSString *)text label.numberOfLines = 0; label.lineBreakMode = NSLineBreakByWordWrapping; label.backgroundColor = [UIColor clearColor]; - + return label; } @@ -541,12 +540,12 @@ - (UILabel *)makeLabelWithText:(NSString *)text - (void)showText:(NSString *)text animated:(BOOL)animated completionHandler:(void(^)())completionHandler { [self saveWrapperViewImageIfNeeded]; - + _textLabel = [self makeLabelWithText:text]; [_wrapperView addSubview:_textLabel]; - + _type = LGPlaceholderViewTypeText; - + [self showAnimated:animated completionHandler:completionHandler]; } @@ -555,21 +554,21 @@ - (void)showText:(NSString *)text animated:(BOOL)animated completionHandler:(voi - (void)showActivityIndicatorWithText:(NSString *)text animated:(BOOL)animated completionHandler:(void(^)())completionHandler { [self saveWrapperViewImageIfNeeded]; - + if (text.length) { _textLabel = [self makeLabelWithText:text]; [_wrapperView addSubview:_textLabel]; } - + _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; _activityIndicator.backgroundColor = [UIColor clearColor]; _activityIndicator.color = _tintColor; [_activityIndicator startAnimating]; [_wrapperView addSubview:_activityIndicator]; - + _type = (text.length ? LGPlaceholderViewTypeActivityIndicatorAndText : LGPlaceholderViewTypeActivityIndicator); - + [self showAnimated:animated completionHandler:completionHandler]; } @@ -583,24 +582,24 @@ - (void)showActivityIndicatorAnimated:(BOOL)animated completionHandler:(void(^)( - (void)showProgressViewWithText:(NSString *)text animated:(BOOL)animated completionHandler:(void(^)())completionHandler { [self saveWrapperViewImageIfNeeded]; - + if (text.length) { _textLabel = [self makeLabelWithText:text]; [_wrapperView addSubview:_textLabel]; } - + _progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; _progressView.backgroundColor = [UIColor clearColor]; _progressView.progressTintColor = _tintColor; [_progressView setProgress:_progressValue animated:NO]; [_wrapperView addSubview:_progressView]; - + _progressLabel = [self makeLabelWithText:_progressText]; [_wrapperView addSubview:_progressLabel]; - + _type = (text.length ? LGPlaceholderViewTypeProgressViewAndText : LGPlaceholderViewTypeProgressView); - + [self showAnimated:animated completionHandler:completionHandler]; } @@ -614,12 +613,12 @@ - (void)showProgressViewAnimated:(BOOL)animated completionHandler:(void(^)())com - (void)showView:(UIView *)view animated:(BOOL)animated completionHandler:(void(^)())completionHandler { [self saveWrapperViewImageIfNeeded]; - + _innerView = view; [_wrapperView addSubview:_innerView]; - + _type = LGPlaceholderViewTypeInnerView; - + [self showAnimated:animated completionHandler:completionHandler]; } @@ -628,44 +627,44 @@ - (void)showView:(UIView *)view animated:(BOOL)animated completionHandler:(void( - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler { _showing = YES; - + // ----- - + if (!self.superview) { _parentViewUserInteractionEnabled = _parentView.userInteractionEnabled; - + _parentView.userInteractionEnabled = !_parentViewUserInteractionDisabled; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { UIScrollView *parentScrollView = (UIScrollView *)_parentView; - + _parentViewShowsHorizontalScrollIndicator = parentScrollView.showsHorizontalScrollIndicator; _parentViewShowsVerticalScrollIndicator = parentScrollView.showsVerticalScrollIndicator; - + parentScrollView.showsHorizontalScrollIndicator = NO; parentScrollView.showsVerticalScrollIndicator = NO; - + if ([_parentView isKindOfClass:[UITableView class]]) { UITableView *parentTableView = (UITableView *)_parentView; - + _parentViewSeparatorStyle = parentTableView.separatorStyle; - + parentTableView.separatorStyle = UITableViewCellSeparatorStyleNone; } } - + [_parentView addSubview:self]; } - + [self layoutInvalidate]; - + // ----- - + [[NSNotificationCenter defaultCenter] postNotificationName:kLGPlaceholderViewWillShowNotification object:self userInfo:nil]; - + [self showDismiss:YES animated:animated completionHandler:^(void) @@ -675,9 +674,9 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl [_savedWrapperView removeFromSuperview]; self.savedWrapperView = nil; } - + if (completionHandler) completionHandler(); - + [[NSNotificationCenter defaultCenter] postNotificationName:kLGPlaceholderViewDidShowNotification object:self userInfo:nil]; }]; } @@ -685,37 +684,37 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl - (void)dismissAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler { if (!self.isShowing) return; - + _showing = NO; - + _parentView.userInteractionEnabled = _parentViewUserInteractionEnabled; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { UIScrollView *parentScrollView = (UIScrollView *)_parentView; - + parentScrollView.showsHorizontalScrollIndicator = _parentViewShowsHorizontalScrollIndicator; parentScrollView.showsVerticalScrollIndicator = _parentViewShowsVerticalScrollIndicator; - + if ([_parentView isKindOfClass:[UITableView class]]) { UITableView *parentTableView = (UITableView *)_parentView; - + parentTableView.separatorStyle = _parentViewSeparatorStyle; } } - + // ----- - + [[NSNotificationCenter defaultCenter] postNotificationName:kLGPlaceholderViewWillDismissNotification object:self userInfo:nil]; - + [self showDismiss:NO animated:animated completionHandler:^(void) { [self removeSubviews]; [self removeFromSuperview]; - + if (completionHandler) completionHandler(); - + [[NSNotificationCenter defaultCenter] postNotificationName:kLGPlaceholderViewDidDismissNotification object:self userInfo:nil]; }]; } @@ -736,7 +735,7 @@ - (void)showDismiss:(BOOL)show animated:(BOOL)animated completionHandler:(void(^ else { [self showDismissAnimations:show]; - + if (completionHandler) completionHandler(); } } @@ -744,10 +743,10 @@ - (void)showDismiss:(BOOL)show animated:(BOOL)animated completionHandler:(void(^ - (void)showDismissAnimations:(BOOL)show { CGFloat value = (show ? 1.f : 0.f); - + _wrapperView.alpha = value; _backgroundView.alpha = value; - + if (show && _savedWrapperView) _savedWrapperView.alpha = 0.f; } @@ -759,9 +758,9 @@ - (void)addObservers if (!self.isObserversAdded && _parentView) { _observersAdded = YES; - + [_parentView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil]; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { [_parentView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil]; @@ -775,9 +774,9 @@ - (void)removeObservers if (self.isObserversAdded && _parentView) { _observersAdded = NO; - + [_parentView removeObserver:self forKeyPath:@"frame"]; - + if ([_parentView isKindOfClass:[UIScrollView class]]) { [_parentView removeObserver:self forKeyPath:@"contentInset"]; @@ -825,15 +824,15 @@ + (void)animateStandardWithAnimations:(void(^)())animations completion:(void(^)( + (UIImage *)screenshotMakeOfView:(UIView *)view inPixels:(BOOL)inPixels { UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, (inPixels ? 1.f : 0.f)); - + CGContextRef context = UIGraphicsGetCurrentContext(); - + [view.layer renderInContext:context]; - + UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext(); - + UIGraphicsEndImageContext(); - + return capturedImage; } diff --git a/README.md b/README.md index 6bb975d..1664976 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,21 @@ For example when you push view controller and want to load some data from server ### With CocoaPods -[CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the "Get Started" section for more details. +CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. To install with cocoaPods, follow the "Get Started" section on [CocoaPods](https://cocoapods.org/). #### Podfile +```ruby +platform :ios, '6.0' +pod 'LGPlaceholderView', '~> 1.0' +``` + +### With Carthage +Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage/). + +#### Cartfile ``` -platform :ios, '6.0' -pod 'LGPlaceholderView', '~> 1.0.0' +github "Friend-LGA/LGPlaceholderView" ~> 1.0 ``` ## Usage