Skip to content

Commit

Permalink
Fixed bug with Slide Over on iOS 9, update default styles and add abi…
Browse files Browse the repository at this point in the history
…lity to set buttons and textFields height and vertical offset
  • Loading branch information
Friend-LGA committed Oct 23, 2015
1 parent 5019e0f commit 926754f
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 385 deletions.
20 changes: 20 additions & 0 deletions Demo/LGAlertViewDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
4A3B78711AD2A28300DB8642 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A3B78701AD2A28300DB8642 /* Images.xcassets */; };
4A3B788B1AD2A93D00DB8642 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A3B788A1AD2A93D00DB8642 /* TableViewController.m */; };
4A3B788E1AD2B29F00DB8642 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A3B788D1AD2B29F00DB8642 /* NavigationController.m */; };
4ABF191C1BDA895200A12B6E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4ABF191B1BDA895200A12B6E /* LaunchScreen.storyboard */; settings = {ASSET_TAGS = (); }; };
92E830BBF9A0E9733AA1BC7E /* libPods-LGAlertViewDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 623B5C352E52555F577FBF72 /* libPods-LGAlertViewDemo.a */; };
/* End PBXBuildFile section */

Expand All @@ -26,6 +27,7 @@
4A3B788A1AD2A93D00DB8642 /* TableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewController.m; sourceTree = "<group>"; };
4A3B788C1AD2B29F00DB8642 /* NavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
4A3B788D1AD2B29F00DB8642 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationController.m; sourceTree = "<group>"; };
4ABF191B1BDA895200A12B6E /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
623B5C352E52555F577FBF72 /* libPods-LGAlertViewDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-LGAlertViewDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
637E642E08EC55B4AF82AB1E /* Pods-LGAlertViewDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LGAlertViewDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LGAlertViewDemo/Pods-LGAlertViewDemo.debug.xcconfig"; sourceTree = "<group>"; };
75F4867B7B8225C0410A3B3A /* Pods-LGAlertViewDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LGAlertViewDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-LGAlertViewDemo/Pods-LGAlertViewDemo.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,6 +74,7 @@
4A3B788A1AD2A93D00DB8642 /* TableViewController.m */,
4A3B78701AD2A28300DB8642 /* Images.xcassets */,
4A3B78631AD2A28200DB8642 /* Supporting Files */,
4ABF191B1BDA895200A12B6E /* LaunchScreen.storyboard */,
);
path = LGAlertViewDemo;
sourceTree = "<group>";
Expand Down Expand Up @@ -114,6 +117,7 @@
4A3B785D1AD2A28200DB8642 /* Frameworks */,
4A3B785E1AD2A28200DB8642 /* Resources */,
29113AC9920AC8E38789F323 /* Copy Pods Resources */,
B520B4BA66BB51ABABA89F86 /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -162,6 +166,7 @@
buildActionMask = 2147483647;
files = (
4A3B78711AD2A28300DB8642 /* Images.xcassets in Resources */,
4ABF191C1BDA895200A12B6E /* LaunchScreen.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -198,6 +203,21 @@
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;
};
B520B4BA66BB51ABABA89F86 /* 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-LGAlertViewDemo/Pods-LGAlertViewDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
4 changes: 2 additions & 2 deletions Demo/LGAlertViewDemo/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.navigationController = [NavigationController new];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.navigationController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

Expand Down
2 changes: 2 additions & 0 deletions Demo/LGAlertViewDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
50 changes: 50 additions & 0 deletions Demo/LGAlertViewDemo/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 Grigory Lutkov. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="20" y="559" width="560" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LGAlertViewDemo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="20" y="180" width="560" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
68 changes: 39 additions & 29 deletions Demo/LGAlertViewDemo/TableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (id)init
if (self)
{
self.title = @"LGAlertView";

_titlesArray = @[@"UIAlertView",
@"LGAlertView + UIView",
@"LGAlertView + Buttons Short",
Expand All @@ -37,7 +37,7 @@ - (id)init
@"LGAlertView + ActivityIndicator",
@"LGAlertView + ProgressView",
@"LGAlertView + Crazy style"];

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}
return self;
Expand All @@ -60,10 +60,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;
}

Expand All @@ -86,7 +86,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
{
UIDatePicker *datePicker = [UIDatePicker new];
datePicker.frame = CGRectMake(0.f, 0.f, datePicker.frame.size.width, 100.f);

[[[LGAlertView alloc] initWithViewStyleWithTitle:@"WOW, it's DatePicker here"
message:@"Choose any date, please"
view:datePicker
Expand Down Expand Up @@ -137,7 +137,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
else if (indexPath.row == 5)
{
[[[LGAlertView alloc] initWithTitle:@"So many buttons..."
message:@"Scroll it, if you can"
message:@"Scroll it"
buttonTitles:@[@"Other 1",
@"Other 2",
@"Other 3",
Expand All @@ -151,7 +151,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
@"Other 12",
@"Other 13",
@"Other 14",
@"Other 15"]
@"Other 15",
@"Other 16",
@"Other 17",
@"Other 18",
@"Other 19",
@"Other 20",
@"Other 21",
@"Other 22",
@"Other 23",
@"Other 24",
@"Other 25"]
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Destructive"
actionHandler:nil
Expand All @@ -161,7 +171,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
else if (indexPath.row == 6)
{
LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"So many buttons..."
message:@"On iPad width will be full screen size. And buttons highlighted colors are grey."
message:@"Scroll it"
buttonTitles:@[@"Other 1",
@"Other 2",
@"Other 3",
Expand All @@ -182,8 +192,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
cancelHandler:nil
destructiveHandler:nil];
alertView.heightMax = 200.f;
alertView.widthMax = CGFLOAT_MAX;
alertView.colorful = NO;
[alertView showAnimated:YES completionHandler:nil];
}
else if (indexPath.row == 7)
Expand All @@ -196,6 +204,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
actionHandler:nil
cancelHandler:nil
destructiveHandler:nil];

alertView.cancelOnTouch = NO;
[alertView showAnimated:YES completionHandler:nil];
}
Expand All @@ -220,7 +229,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
actionHandler:nil
cancelHandler:nil
destructiveHandler:nil];

alertView.cancelOnTouch = NO;
[alertView showAnimated:YES completionHandler:nil];
}
Expand All @@ -231,15 +239,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
numberOfTextFields:15
textFieldsSetupHandler:^(UITextField *textField, NSUInteger index)
{
textField.placeholder = [NSString stringWithFormat:@"Beautiful placeholder %i", (int)index];
textField.placeholder = [NSString stringWithFormat:@"Beautiful placeholder %i", (int)index+1];
}
buttonTitles:@[@"Done"]
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
actionHandler:nil
cancelHandler:nil
destructiveHandler:nil];

alertView.cancelOnTouch = NO;
[alertView showAnimated:YES completionHandler:nil];
}
Expand Down Expand Up @@ -269,7 +276,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
destructiveHandler:nil];
alertView.cancelOnTouch = NO;
[alertView showAnimated:YES completionHandler:nil];

[self updateProgressWithAlertView:alertView];
}
else if (indexPath.row == 12)
Expand All @@ -282,41 +289,44 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
actionHandler:nil
cancelHandler:nil
destructiveHandler:nil];

alertView.backgroundColor = [UIColor colorWithWhite:1.f alpha:0.8];

alertView.offsetVertical = 0;
alertView.buttonsHeight = 64.f;
alertView.width = CGFLOAT_MAX;

alertView.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.8];
alertView.layerBorderWidth = 1.f;
alertView.layerBorderColor = [UIColor redColor];
alertView.layerCornerRadius = 0.f;
alertView.layerShadowColor = [UIColor colorWithWhite:0.f alpha:0.5];
alertView.layerShadowRadius = 5.f;

alertView.titleTextAlignment = NSTextAlignmentRight;
alertView.titleTextColor = [UIColor whiteColor];

alertView.messageTextAlignment = NSTextAlignmentLeft;
alertView.messageTextColor = [UIColor whiteColor];

alertView.separatorsColor = [UIColor colorWithWhite:0.6 alpha:1.f];

alertView.tintColor = [UIColor greenColor];

alertView.buttonsTitleColorHighlighted = [UIColor blackColor];

alertView.cancelButtonTitleColor = [UIColor cyanColor];
alertView.cancelButtonTitleColorHighlighted = [UIColor blackColor];
alertView.cancelButtonBackgroundColorHighlighted = [UIColor cyanColor];

alertView.destructiveButtonTitleColor = [UIColor yellowColor];
alertView.destructiveButtonTitleColorHighlighted = [UIColor blackColor];
alertView.destructiveButtonBackgroundColorHighlighted = [UIColor yellowColor];

// And much more settings you can apply, check it in LGAlertView class

[alertView showAnimated:YES completionHandler:nil];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

Expand All @@ -329,12 +339,12 @@ - (void)updateProgressWithAlertView:(LGAlertView *)alertView
else
{
float progress = alertView.progress+0.0025;

if (progress > 1.f)
progress = 1.f;

[alertView setProgress:progress progressLabelText:[NSString stringWithFormat:@"%.0f %%", progress*100]];

[self updateProgressWithAlertView:alertView];
}
});
Expand Down
6 changes: 3 additions & 3 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- LGAlertView (1.0.3)
- LGAlertView (1.0.4)

DEPENDENCIES:
- LGAlertView (from `../`)
Expand All @@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
LGAlertView: 0b07e39c4f1cfe28dd7f4054fad352a45e92b2a9
LGAlertView: 2c0405af11a4622accd2acf06fa1fb0eadb1ccf7

COCOAPODS: 0.38.0
COCOAPODS: 0.39.0
2 changes: 1 addition & 1 deletion LGAlertView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'LGAlertView'
s.version = '1.0.3'
s.version = '1.1.0'
s.platform = :ios, '6.0'
s.license = 'MIT'
s.homepage = 'https://github.com/Friend-LGA/LGAlertView'
Expand Down
Loading

0 comments on commit 926754f

Please sign in to comment.