Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated README, added demo

  • Loading branch information...
commit b03601071604c3385c919f80731c7e822db15ddd 1 parent 7cee2e2
@mikefrederick authored
Showing with 1,646 additions and 36 deletions.
  1. +8 −8 { → MFSlidingView}/MFSlidingView.h
  2. +17 −28 { → MFSlidingView}/MFSlidingView.m
  3. +297 −0 MFSlidingViewDemo.xcodeproj/project.pbxproj
  4. +7 −0 MFSlidingViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  5. BIN  MFSlidingViewDemo.xcodeproj/project.xcworkspace/xcuserdata/Mike.xcuserdatad/UserInterfaceState.xcuserstate
  6. +10 −0 MFSlidingViewDemo.xcodeproj/project.xcworkspace/xcuserdata/Mike.xcuserdatad/WorkspaceSettings.xcsettings
  7. +85 −0 MFSlidingViewDemo.xcodeproj/xcuserdata/Mike.xcuserdatad/xcschemes/MFSlidingViewDemo.xcscheme
  8. +22 −0 MFSlidingViewDemo.xcodeproj/xcuserdata/Mike.xcuserdatad/xcschemes/xcschememanagement.plist
  9. +19 −0 MFSlidingViewDemo/DemoViewController.h
  10. +84 −0 MFSlidingViewDemo/DemoViewController.m
  11. +19 −0 MFSlidingViewDemo/MFAppDelegate.h
  12. +64 −0 MFSlidingViewDemo/MFAppDelegate.m
  13. +56 −0 MFSlidingViewDemo/MFSlidingView.h
  14. +455 −0 MFSlidingViewDemo/MFSlidingView.m
  15. +45 −0 MFSlidingViewDemo/MFSlidingViewDemo-Info.plist
  16. +14 −0 MFSlidingViewDemo/MFSlidingViewDemo-Prefix.pch
  17. 0  MFSlidingViewDemo/README
  18. +382 −0 MFSlidingViewDemo/en.lproj/DemoViewController.xib
  19. +2 −0  MFSlidingViewDemo/en.lproj/InfoPlist.strings
  20. +18 −0 MFSlidingViewDemo/main.m
  21. +42 −0 README
View
16 MFSlidingView.h → MFSlidingView/MFSlidingView.h
@@ -2,11 +2,12 @@
// MFSlidingView.h
//
// Created by Michael Frederick on 7/13/11.
-// Copyright 2011 University of Wisconsin - Madison. All rights reserved.
+// Copyright 2011 Michael Frederick. All rights reserved.
//
#import <UIKit/UIKit.h>
+// where should the view slide in from?
typedef enum {
LeftOfScreen,
RightOfScreen,
@@ -14,6 +15,7 @@ typedef enum {
BelowScreen
} SlidingViewOffScreenPosition;
+// where should the view slide in to?
typedef enum {
BottomOfScreen,
MiddleOfScreen,
@@ -21,13 +23,11 @@ typedef enum {
} SlidingViewOnScreenPosition;
typedef enum {
- ShowToolbar = 1,
- ShowDoneButton = 2,
- ShowCancelButton = 4,
- AvoidKeyboard = 8,
- CancelOnBackgroundPressed = 16,
- FitSizeToContentView = 32,
- PositionToolbarOnBottom = 64
+ ShowDoneButton = 1, // show a done button on the toolbar
+ ShowCancelButton = 2, // show a cancel button on the toolbar
+ AvoidKeyboard = 4, // useful with a uitextfield or uitextview in the content view
+ CancelOnBackgroundPressed = 8, // cancelBlock will be executed when background tapped
+ PositionToolbarOnBottom = 16 // position the toolbar on the bottom of the content view
} SlidingViewOptions;
View
45 MFSlidingView.m → MFSlidingView/MFSlidingView.m
@@ -2,29 +2,31 @@
// MFSlidingView.m
//
// Created by Michael Frederick on 7/13/11.
-// Copyright 2011 University of Wisconsin - Madison. All rights reserved.
+// Copyright 2011 Michael Frederick. All rights reserved.
//
#import "MFSlidingView.h"
#import <QuartzCore/QuartzCore.h>
-#import "UI.h"
#define BITMASK_CONTAINS_OPTION(bitmask,option) ((bitmask & option) == option)
typedef void (^MFBlock)(void);
@interface MFSlidingView () {
+ // contains the content view + the toolbar
UIView *bodyView;
+ // used for keyboard avoidance
CGRect framePriorToKeyboardMovement;
}
+
@property (nonatomic, assign) UIView *containerView;
+// the view that is "sliding in"
@property (nonatomic, assign) UIView *contentView;
@property (nonatomic, readonly) BOOL showDoneButton;
@property (nonatomic, readonly) BOOL showCancelButton;
@property (nonatomic, readonly) BOOL showToolbar;
@property (nonatomic, readonly) BOOL avoidKeyboard;
-@property (nonatomic, readonly) BOOL fitSizeToContentView;
@property (nonatomic, readonly) BOOL positionToolbarOnBottom;
@property (nonatomic, assign) SlidingViewOptions options;
@property (nonatomic, assign) SlidingViewOnScreenPosition finalPosition;
@@ -54,7 +56,6 @@ @implementation MFSlidingView
@synthesize showCancelButton;
@synthesize showToolbar;
@synthesize avoidKeyboard;
-@synthesize fitSizeToContentView;
@synthesize contentView;
@synthesize options;
@synthesize initialPosition;
@@ -90,9 +91,8 @@ + (MFSlidingView *) slideView:(UIView *)view
onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition
offScreenPosition:(SlidingViewOffScreenPosition)offScreenPosition {
- SlidingViewOptions options = ShowToolbar|ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed;
- if(onScreenPosition == MiddleOfScreen) options = options|FitSizeToContentView;
- else if (onScreenPosition == TopOfScreen) options = options|PositionToolbarOnBottom;
+ SlidingViewOptions options = ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed;
+ if (onScreenPosition == TopOfScreen) options = options|PositionToolbarOnBottom;
return [MFSlidingView slideView:view intoView:wrapper
onScreenPosition:onScreenPosition offScreenPosition:offScreenPosition
@@ -155,18 +155,13 @@ - (BOOL) showCancelButton {
}
- (BOOL) showToolbar {
- if(self.showDoneButton || self.showCancelButton || self.title) return YES;
- return BITMASK_CONTAINS_OPTION(self.options, ShowToolbar);
+ return (self.showDoneButton || self.showCancelButton || self.title);
}
- (BOOL) avoidKeyboard {
return BITMASK_CONTAINS_OPTION(self.options, AvoidKeyboard);
}
-- (BOOL) fitSizeToContentView {
- return BITMASK_CONTAINS_OPTION(self.options, FitSizeToContentView);
-}
-
- (BOOL) positionToolbarOnBottom {
return BITMASK_CONTAINS_OPTION(self.options, PositionToolbarOnBottom);
}
@@ -203,7 +198,6 @@ - (void) drawToolbar {
CGFloat y = (self.positionToolbarOnBottom) ? self.contentFrame.size.height : 0;
self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, y, bodyView.frame.size.width, 44)];
- self.toolbar.tintColor = kDarkBlueColor;
NSMutableArray *toolbarItems = [NSMutableArray new];
@@ -226,11 +220,8 @@ - (void) drawToolbar {
- (CGPoint) offScreenCoordinates {
CGRect frame = [self bodyFrame];
- CGPoint initialCoordinates = CGPointZero;
- CGPoint finalCoordinates = [self onScreenCoordinates];;
- if(self.fitSizeToContentView) {
- initialCoordinates.x = (self.containerView.bounds.size.width - frame.size.width)/2;
- }
+ CGPoint initialCoordinates = CGPointMake((self.containerView.bounds.size.width - frame.size.width)/2, 0);
+ CGPoint finalCoordinates = [self onScreenCoordinates];
switch (self.initialPosition) {
case BelowScreen:
@@ -256,12 +247,8 @@ - (CGPoint) offScreenCoordinates {
- (CGPoint) onScreenCoordinates {
CGRect frame = [self bodyFrame];
- CGPoint finalCoordinates = CGPointZero;
-
- if(self.fitSizeToContentView) {
- finalCoordinates.x = (self.containerView.bounds.size.width - frame.size.width)/2;
- }
-
+ CGPoint finalCoordinates = CGPointMake((self.containerView.bounds.size.width - frame.size.width)/2, 0);
+
switch (self.finalPosition) {
case TopOfScreen:
finalCoordinates.y = 0.0;
@@ -277,6 +264,7 @@ - (CGPoint) onScreenCoordinates {
return finalCoordinates;
}
+// frame of the content view
- (CGRect) contentFrame {
CGRect frame = self.contentView.frame;
frame.origin.x = 0;
@@ -284,6 +272,7 @@ - (CGRect) contentFrame {
return frame;
}
+// frame of the content view + toolbar
- (CGRect) bodyFrame {
CGRect frame = bodyView.frame;
frame.size = self.contentView.frame.size;
@@ -304,7 +293,7 @@ - (void) slideIntoView:(UIView *)wrapper
name:UIKeyboardWillHideNotification object:nil];
}
- if(self.fitSizeToContentView) {
+ if(self.contentView.frame.size.width < self.containerView.frame.size.width) {
bodyView.backgroundColor = [UIColor blackColor];
bodyView.clipsToBounds = YES;
bodyView.layer.cornerRadius = 5;
@@ -367,12 +356,12 @@ - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished c
- (void) cancelPressed:(id)sender {
if(self.cancelBlock) self.cancelBlock();
- [self slideOut];
+ else [self slideOut];
}
- (void) donePressed:(id)sender {
if(self.doneBlock) self.doneBlock();
- [self slideOut];
+ else [self slideOut];
}
// Search recursively for first responder
View
297 MFSlidingViewDemo.xcodeproj/project.pbxproj
@@ -0,0 +1,297 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 27F624E615525B170010B0CC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27F624E515525B170010B0CC /* UIKit.framework */; };
+ 27F624E815525B170010B0CC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27F624E715525B170010B0CC /* Foundation.framework */; };
+ 27F624EA15525B170010B0CC /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27F624E915525B170010B0CC /* CoreGraphics.framework */; };
+ 27F624F015525B170010B0CC /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 27F624EE15525B170010B0CC /* InfoPlist.strings */; };
+ 27F624F215525B170010B0CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F624F115525B170010B0CC /* main.m */; };
+ 27F624F615525B170010B0CC /* MFAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F624F515525B170010B0CC /* MFAppDelegate.m */; };
+ 27F624F915525B170010B0CC /* DemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F624F815525B170010B0CC /* DemoViewController.m */; };
+ 27F624FC15525B170010B0CC /* DemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 27F624FA15525B170010B0CC /* DemoViewController.xib */; };
+ 27F6250915525B530010B0CC /* MFSlidingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F6250715525B530010B0CC /* MFSlidingView.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 27F624E115525B170010B0CC /* MFSlidingViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MFSlidingViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 27F624E515525B170010B0CC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 27F624E715525B170010B0CC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 27F624E915525B170010B0CC /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 27F624ED15525B170010B0CC /* MFSlidingViewDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MFSlidingViewDemo-Info.plist"; sourceTree = "<group>"; };
+ 27F624EF15525B170010B0CC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 27F624F115525B170010B0CC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 27F624F315525B170010B0CC /* MFSlidingViewDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MFSlidingViewDemo-Prefix.pch"; sourceTree = "<group>"; };
+ 27F624F415525B170010B0CC /* MFAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFAppDelegate.h; sourceTree = "<group>"; };
+ 27F624F515525B170010B0CC /* MFAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MFAppDelegate.m; sourceTree = "<group>"; };
+ 27F624F715525B170010B0CC /* DemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DemoViewController.h; sourceTree = "<group>"; };
+ 27F624F815525B170010B0CC /* DemoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DemoViewController.m; sourceTree = "<group>"; };
+ 27F624FB15525B170010B0CC /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DemoViewController.xib; sourceTree = "<group>"; };
+ 27F6250615525B530010B0CC /* MFSlidingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFSlidingView.h; sourceTree = "<group>"; };
+ 27F6250715525B530010B0CC /* MFSlidingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFSlidingView.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 27F624DE15525B170010B0CC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 27F624E615525B170010B0CC /* UIKit.framework in Frameworks */,
+ 27F624E815525B170010B0CC /* Foundation.framework in Frameworks */,
+ 27F624EA15525B170010B0CC /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 27F624D615525B170010B0CC = {
+ isa = PBXGroup;
+ children = (
+ 27F6250515525B530010B0CC /* MFSlidingView */,
+ 27F624EB15525B170010B0CC /* MFSlidingViewDemo */,
+ 27F624E415525B170010B0CC /* Frameworks */,
+ 27F624E215525B170010B0CC /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 27F624E215525B170010B0CC /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 27F624E115525B170010B0CC /* MFSlidingViewDemo.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 27F624E415525B170010B0CC /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 27F624E515525B170010B0CC /* UIKit.framework */,
+ 27F624E715525B170010B0CC /* Foundation.framework */,
+ 27F624E915525B170010B0CC /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 27F624EB15525B170010B0CC /* MFSlidingViewDemo */ = {
+ isa = PBXGroup;
+ children = (
+ 27F624F415525B170010B0CC /* MFAppDelegate.h */,
+ 27F624F515525B170010B0CC /* MFAppDelegate.m */,
+ 27F624F715525B170010B0CC /* DemoViewController.h */,
+ 27F624F815525B170010B0CC /* DemoViewController.m */,
+ 27F624FA15525B170010B0CC /* DemoViewController.xib */,
+ 27F624EC15525B170010B0CC /* Supporting Files */,
+ );
+ path = MFSlidingViewDemo;
+ sourceTree = "<group>";
+ };
+ 27F624EC15525B170010B0CC /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 27F624ED15525B170010B0CC /* MFSlidingViewDemo-Info.plist */,
+ 27F624EE15525B170010B0CC /* InfoPlist.strings */,
+ 27F624F115525B170010B0CC /* main.m */,
+ 27F624F315525B170010B0CC /* MFSlidingViewDemo-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 27F6250515525B530010B0CC /* MFSlidingView */ = {
+ isa = PBXGroup;
+ children = (
+ 27F6250615525B530010B0CC /* MFSlidingView.h */,
+ 27F6250715525B530010B0CC /* MFSlidingView.m */,
+ );
+ path = MFSlidingView;
+ sourceTree = SOURCE_ROOT;
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 27F624E015525B170010B0CC /* MFSlidingViewDemo */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 27F6250215525B170010B0CC /* Build configuration list for PBXNativeTarget "MFSlidingViewDemo" */;
+ buildPhases = (
+ 27F624DD15525B170010B0CC /* Sources */,
+ 27F624DE15525B170010B0CC /* Frameworks */,
+ 27F624DF15525B170010B0CC /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = MFSlidingViewDemo;
+ productName = MFSlidingViewDemo;
+ productReference = 27F624E115525B170010B0CC /* MFSlidingViewDemo.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 27F624D815525B170010B0CC /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ CLASSPREFIX = MF;
+ LastUpgradeCheck = 0430;
+ ORGANIZATIONNAME = "University of Wisconsin - Madison";
+ };
+ buildConfigurationList = 27F624DB15525B170010B0CC /* Build configuration list for PBXProject "MFSlidingViewDemo" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 27F624D615525B170010B0CC;
+ productRefGroup = 27F624E215525B170010B0CC /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 27F624E015525B170010B0CC /* MFSlidingViewDemo */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 27F624DF15525B170010B0CC /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 27F624F015525B170010B0CC /* InfoPlist.strings in Resources */,
+ 27F624FC15525B170010B0CC /* DemoViewController.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 27F624DD15525B170010B0CC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 27F624F215525B170010B0CC /* main.m in Sources */,
+ 27F624F615525B170010B0CC /* MFAppDelegate.m in Sources */,
+ 27F624F915525B170010B0CC /* DemoViewController.m in Sources */,
+ 27F6250915525B530010B0CC /* MFSlidingView.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 27F624EE15525B170010B0CC /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 27F624EF15525B170010B0CC /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 27F624FA15525B170010B0CC /* DemoViewController.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 27F624FB15525B170010B0CC /* en */,
+ );
+ name = DemoViewController.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 27F6250015525B170010B0CC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "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_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 27F6250115525B170010B0CC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 27F6250315525B170010B0CC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "MFSlidingViewDemo/MFSlidingViewDemo-Prefix.pch";
+ INFOPLIST_FILE = "MFSlidingViewDemo/MFSlidingViewDemo-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 27F6250415525B170010B0CC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "MFSlidingViewDemo/MFSlidingViewDemo-Prefix.pch";
+ INFOPLIST_FILE = "MFSlidingViewDemo/MFSlidingViewDemo-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 27F624DB15525B170010B0CC /* Build configuration list for PBXProject "MFSlidingViewDemo" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 27F6250015525B170010B0CC /* Debug */,
+ 27F6250115525B170010B0CC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 27F6250215525B170010B0CC /* Build configuration list for PBXNativeTarget "MFSlidingViewDemo" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 27F6250315525B170010B0CC /* Debug */,
+ 27F6250415525B170010B0CC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 27F624D815525B170010B0CC /* Project object */;
+}
View
7 MFSlidingViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:MFSlidingViewDemo.xcodeproj">
+ </FileRef>
+</Workspace>
View
BIN  MFSlidingViewDemo.xcodeproj/project.xcworkspace/xcuserdata/Mike.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown
View
10 MFSlidingViewDemo.xcodeproj/project.xcworkspace/xcuserdata/Mike.xcuserdatad/WorkspaceSettings.xcsettings
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
+ <true/>
+ <key>SnapshotAutomaticallyBeforeSignificantChanges</key>
+ <true/>
+</dict>
+</plist>
View
85 MFSlidingViewDemo.xcodeproj/xcuserdata/Mike.xcuserdatad/xcschemes/MFSlidingViewDemo.xcscheme
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "27F624E015525B170010B0CC"
+ BuildableName = "MFSlidingViewDemo.app"
+ BlueprintName = "MFSlidingViewDemo"
+ ReferencedContainer = "container:MFSlidingViewDemo.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "27F624E015525B170010B0CC"
+ BuildableName = "MFSlidingViewDemo.app"
+ BlueprintName = "MFSlidingViewDemo"
+ ReferencedContainer = "container:MFSlidingViewDemo.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "27F624E015525B170010B0CC"
+ BuildableName = "MFSlidingViewDemo.app"
+ BlueprintName = "MFSlidingViewDemo"
+ ReferencedContainer = "container:MFSlidingViewDemo.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "27F624E015525B170010B0CC"
+ BuildableName = "MFSlidingViewDemo.app"
+ BlueprintName = "MFSlidingViewDemo"
+ ReferencedContainer = "container:MFSlidingViewDemo.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
View
22 MFSlidingViewDemo.xcodeproj/xcuserdata/Mike.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SchemeUserState</key>
+ <dict>
+ <key>MFSlidingViewDemo.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>27F624E015525B170010B0CC</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
View
19 MFSlidingViewDemo/DemoViewController.h
@@ -0,0 +1,19 @@
+//
+// MFViewController.h
+// MFSlidingViewDemo
+//
+// Created by Michael Frederick on 5/3/12.
+// Copyright (c) 2012 Michael Frederick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "MFSlidingView.h"
+
+@interface DemoViewController : UIViewController<UIActionSheetDelegate> {
+ IBOutlet UIView *view1;
+ IBOutlet UIView *view2;
+}
+
+- (IBAction)buttonPressed:(id)sender;
+
+@end
View
84 MFSlidingViewDemo/DemoViewController.m
@@ -0,0 +1,84 @@
+//
+// MFViewController.m
+// MFSlidingViewDemo
+//
+// Created by Michael Frederick on 5/3/12.
+// Copyright (c) 2012 Michael Frederick. All rights reserved.
+//
+
+#import "DemoViewController.h"
+
+@interface DemoViewController ()
+
+@end
+
+@implementation DemoViewController
+
+- (IBAction)buttonPressed:(id)sender {
+ UIActionSheet *actionSheet = [[UIActionSheet alloc]
+ initWithTitle:@"Select A Demo" delegate:self
+ cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
+ otherButtonTitles:@"UIDatePicker", @"Random View",
+ @"Keyboard Avoidance",
+ @"View On Top",
+ nil];
+ [actionSheet showInView:self.view];
+}
+
+
+#pragma mark - UIActionSheetDelegate
+
+- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
+ NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
+ if([buttonTitle isEqualToString:@"UIDatePicker"]) {
+ [MFSlidingView slideView:[[[UIDatePicker alloc] init] autorelease] intoView:self.view
+ onScreenPosition:BottomOfScreen];
+ } else if([buttonTitle isEqualToString:@"Random View"]) {
+ [MFSlidingView slideView:view1 intoView:self.view
+ onScreenPosition:MiddleOfScreen offScreenPosition:LeftOfScreen];
+ } else if([buttonTitle isEqualToString:@"Keyboard Avoidance"]) {
+ SlidingViewOptions options = ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed|AvoidKeyboard;
+ void (^cancelOrDoneBlock)() = ^{
+ // we must manually slide out the view out if we specify this block
+ [MFSlidingView slideOut];
+ };
+
+ [MFSlidingView slideView:view2 intoView:self.view
+ onScreenPosition:BottomOfScreen
+ offScreenPosition:BelowScreen title:@"Avoid Keyboard"
+ options:options
+ doneBlock:cancelOrDoneBlock
+ cancelBlock:cancelOrDoneBlock];
+ } else if([buttonTitle isEqualToString:@"View On Top"]) {
+ [MFSlidingView slideView:view2 intoView:self.view
+ onScreenPosition:TopOfScreen
+ offScreenPosition:AboveScreen title:@"Woohoo"
+ options:ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed|PositionToolbarOnBottom
+ doneBlock:nil
+ cancelBlock:nil];
+ }
+}
+
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+ } else {
+ return YES;
+ }
+}
+
+@end
View
19 MFSlidingViewDemo/MFAppDelegate.h
@@ -0,0 +1,19 @@
+//
+// MFAppDelegate.h
+// MFSlidingViewDemo
+//
+// Created by Michael Frederick on 5/3/12.
+// Copyright (c) 2012 Michael Frederick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class DemoViewController;
+
+@interface MFAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) DemoViewController *viewController;
+
+@end
View
64 MFSlidingViewDemo/MFAppDelegate.m
@@ -0,0 +1,64 @@
+//
+// MFAppDelegate.m
+// MFSlidingViewDemo
+//
+// Created by Michael Frederick on 5/3/12.
+// Copyright (c) 2012 Michael Frederick. All rights reserved.
+//
+
+#import "MFAppDelegate.h"
+
+#import "DemoViewController.h"
+
+@implementation MFAppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+- (void)dealloc
+{
+ [_window release];
+ [_viewController release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ // Override point for customization after application launch.
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ self.viewController = [[[DemoViewController alloc] initWithNibName:@"DemoViewController" bundle:nil] autorelease];
+ }
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
View
56 MFSlidingViewDemo/MFSlidingView.h
@@ -0,0 +1,56 @@
+//
+// MFSlidingView.h
+//
+// Created by Michael Frederick on 7/13/11.
+// Copyright 2011 Michael Frederick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+// where should the view slide in from?
+typedef enum {
+ LeftOfScreen,
+ RightOfScreen,
+ AboveScreen,
+ BelowScreen
+} SlidingViewOffScreenPosition;
+
+// where should the view slide in to?
+typedef enum {
+ BottomOfScreen,
+ MiddleOfScreen,
+ TopOfScreen
+} SlidingViewOnScreenPosition;
+
+typedef enum {
+ ShowDoneButton = 1, // show a done button on the toolbar
+ ShowCancelButton = 2, // show a cancel button on the toolbar
+ AvoidKeyboard = 4, // useful with a uitextfield or uitextview in the content view
+ CancelOnBackgroundPressed = 8, // cancelBlock will be executed when background tapped
+ PositionToolbarOnBottom = 16 // position the toolbar on the bottom of the content view
+} SlidingViewOptions;
+
+
+@interface MFSlidingView : UIView
+
++ (MFSlidingView *) slideView:(UIView *)contentView
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition;
+
++ (MFSlidingView *) slideView:(UIView *)view
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition
+ offScreenPosition:(SlidingViewOffScreenPosition)offScreenPosition;
+
++ (MFSlidingView *) slideView:(UIView *)view
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition
+ offScreenPosition:(SlidingViewOffScreenPosition)offScreenPosition
+ title:(NSString *)title
+ options:(SlidingViewOptions)options
+ doneBlock:(void (^)())doneBlock
+ cancelBlock:(void (^)())cancelBlock;
+
++ (void) slideOut;
+
+@end
View
455 MFSlidingViewDemo/MFSlidingView.m
@@ -0,0 +1,455 @@
+//
+// MFSlidingView.m
+//
+// Created by Michael Frederick on 7/13/11.
+// Copyright 2011 Michael Frederick. All rights reserved.
+//
+
+#import "MFSlidingView.h"
+#import <QuartzCore/QuartzCore.h>
+
+#define BITMASK_CONTAINS_OPTION(bitmask,option) ((bitmask & option) == option)
+
+typedef void (^MFBlock)(void);
+
+@interface MFSlidingView () {
+ // contains the content view + the toolbar
+ UIView *bodyView;
+ // used for keyboard avoidance
+ CGRect framePriorToKeyboardMovement;
+}
+
+
+@property (nonatomic, assign) UIView *containerView;
+// the view that is "sliding in"
+@property (nonatomic, assign) UIView *contentView;
+@property (nonatomic, readonly) BOOL showDoneButton;
+@property (nonatomic, readonly) BOOL showCancelButton;
+@property (nonatomic, readonly) BOOL showToolbar;
+@property (nonatomic, readonly) BOOL avoidKeyboard;
+@property (nonatomic, readonly) BOOL positionToolbarOnBottom;
+@property (nonatomic, assign) SlidingViewOptions options;
+@property (nonatomic, assign) SlidingViewOnScreenPosition finalPosition;
+@property (nonatomic, assign) SlidingViewOffScreenPosition initialPosition;
+@property (readwrite, nonatomic, copy) MFBlock doneBlock;
+@property (readwrite, nonatomic, copy) MFBlock cancelBlock;
+@property (nonatomic, strong) NSString *title;
+@property (nonatomic, strong) UIToolbar *toolbar;
+
+- (id) initWithContentView:(UIView *)view;
+- (void) slideIntoView:(UIView *)wrapper;
+- (void) slideOut;
+- (BOOL) adjustToFirstResponder;
+
+- (CGPoint) offScreenCoordinates;
+- (CGPoint) onScreenCoordinates;
+
+- (CGRect)contentFrame;
+- (CGRect)bodyFrame;
+
+@end
+
+
+@implementation MFSlidingView
+
+@synthesize showDoneButton;
+@synthesize showCancelButton;
+@synthesize showToolbar;
+@synthesize avoidKeyboard;
+@synthesize contentView;
+@synthesize options;
+@synthesize initialPosition;
+@synthesize finalPosition;
+@synthesize cancelBlock;
+@synthesize doneBlock;
+@synthesize title;
+@synthesize toolbar;
+@synthesize containerView;
+
+static MFSlidingView *sharedView = nil;
+
++ (MFSlidingView *) slideView:(UIView *)contentView
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition {
+ SlidingViewOffScreenPosition offScreenPosition;
+ switch (onScreenPosition) {
+ case BottomOfScreen:
+ case MiddleOfScreen:
+ offScreenPosition = BelowScreen;
+ break;
+ case TopOfScreen:
+ offScreenPosition = AboveScreen;
+ break;
+ }
+
+ return [MFSlidingView slideView:contentView intoView:wrapper
+ onScreenPosition:onScreenPosition offScreenPosition:offScreenPosition];
+}
+
++ (MFSlidingView *) slideView:(UIView *)view
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition
+ offScreenPosition:(SlidingViewOffScreenPosition)offScreenPosition {
+
+ SlidingViewOptions options = ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed;
+ if (onScreenPosition == TopOfScreen) options = options|PositionToolbarOnBottom;
+
+ return [MFSlidingView slideView:view intoView:wrapper
+ onScreenPosition:onScreenPosition offScreenPosition:offScreenPosition
+ title:nil options:options doneBlock:nil cancelBlock:nil];
+}
+
++ (MFSlidingView *) slideView:(UIView *)view
+ intoView:(UIView *)wrapper
+ onScreenPosition:(SlidingViewOnScreenPosition)onScreenPosition
+ offScreenPosition:(SlidingViewOffScreenPosition)offScreenPosition
+ title:(NSString *)title
+ options:(SlidingViewOptions)options
+ doneBlock:(void (^)())doneBlock
+ cancelBlock:(void (^)())cancelBlock {
+
+ MFSlidingView *slidingView = [[MFSlidingView alloc] initWithContentView:view];
+ slidingView.doneBlock = doneBlock;
+ slidingView.cancelBlock = cancelBlock;
+ slidingView.options = options;
+ slidingView.title = title;
+ slidingView.initialPosition = offScreenPosition;
+ slidingView.finalPosition = onScreenPosition;
+ [slidingView slideIntoView:wrapper];
+
+ sharedView = slidingView;
+
+ return slidingView;
+}
+
++ (void) slideOut {
+ if(!sharedView) return;
+ [sharedView slideOut];
+ sharedView = nil;
+}
+
+- (void) dealloc {
+ self.toolbar = nil;
+ self.title = nil;
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (id) initWithContentView:(UIView *)view {
+ self = [super init];
+ if (self) {
+ // Initialization code
+ bodyView = [[UIView alloc]
+ initWithFrame:CGRectZero];
+ [self addSubview:bodyView];
+ self.contentView = view;
+ }
+ return self;
+}
+
+- (BOOL) showDoneButton {
+ return BITMASK_CONTAINS_OPTION(self.options, ShowDoneButton);
+}
+
+- (BOOL) showCancelButton {
+ return BITMASK_CONTAINS_OPTION(self.options, ShowCancelButton);
+}
+
+- (BOOL) showToolbar {
+ return (self.showDoneButton || self.showCancelButton || self.title);
+}
+
+- (BOOL) avoidKeyboard {
+ return BITMASK_CONTAINS_OPTION(self.options, AvoidKeyboard);
+}
+
+- (BOOL) positionToolbarOnBottom {
+ return BITMASK_CONTAINS_OPTION(self.options, PositionToolbarOnBottom);
+}
+
+- (UIBarButtonItem *)doneButtonItem {
+ return [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
+ target:self action:@selector(donePressed:)];
+}
+
+- (UIBarButtonItem *)cancelButtonItem {
+ return [[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
+ target:self action:@selector(cancelPressed:)];
+}
+
+- (UIBarButtonItem *)titleButtonItem {
+ UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
+ label.backgroundColor = [UIColor clearColor];
+ label.text = self.title;
+ label.textColor = [UIColor whiteColor];
+ label.font = [UIFont boldSystemFontOfSize:18];
+ [label sizeToFit];
+ return [[UIBarButtonItem alloc] initWithCustomView:label];
+}
+
+- (UIBarButtonItem *)flexButtonItem {
+ return [[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
+ target:nil action:nil];
+}
+
+- (void) drawToolbar {
+ if(!self.showToolbar) return;
+
+ CGFloat y = (self.positionToolbarOnBottom) ? self.contentFrame.size.height : 0;
+ self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, y, bodyView.frame.size.width, 44)];
+
+ NSMutableArray *toolbarItems = [NSMutableArray new];
+
+ if(self.showCancelButton) {
+ [toolbarItems addObject:self.cancelButtonItem];
+ [toolbarItems addObject:self.flexButtonItem];
+ }
+
+ if(self.title) {
+ [toolbarItems addObject:self.titleButtonItem];
+ [toolbarItems addObject:self.flexButtonItem];
+ }
+
+ if(self.showDoneButton) [toolbarItems addObject:self.doneButtonItem];
+
+ self.toolbar.items = toolbarItems;
+
+ [bodyView addSubview:self.toolbar];
+}
+
+- (CGPoint) offScreenCoordinates {
+ CGRect frame = [self bodyFrame];
+ CGPoint initialCoordinates = CGPointMake((self.containerView.bounds.size.width - frame.size.width)/2, 0);
+ CGPoint finalCoordinates = [self onScreenCoordinates];
+
+ switch (self.initialPosition) {
+ case BelowScreen:
+ initialCoordinates.x = finalCoordinates.x;
+ initialCoordinates.y = self.containerView.bounds.size.height;
+ break;
+ case AboveScreen:
+ initialCoordinates.x = finalCoordinates.x;
+ initialCoordinates.y = -1*frame.size.height;
+ break;
+ case LeftOfScreen:
+ initialCoordinates.x = -1*frame.size.width;
+ initialCoordinates.y = finalCoordinates.y;
+ break;
+ case RightOfScreen:
+ initialCoordinates.x = self.containerView.bounds.size.width + frame.size.width;
+ initialCoordinates.y = finalCoordinates.y;
+ break;
+ }
+
+ return initialCoordinates;
+}
+
+- (CGPoint) onScreenCoordinates {
+ CGRect frame = [self bodyFrame];
+ CGPoint finalCoordinates = CGPointMake((self.containerView.bounds.size.width - frame.size.width)/2, 0);
+
+ switch (self.finalPosition) {
+ case TopOfScreen:
+ finalCoordinates.y = 0.0;
+ break;
+ case MiddleOfScreen:
+ finalCoordinates.y = (self.containerView.bounds.size.height - frame.size.height)/2;
+ break;
+ case BottomOfScreen:
+ finalCoordinates.y = self.containerView.bounds.size.height - frame.size.height;
+ break;
+ }
+
+ return finalCoordinates;
+}
+
+// frame of the content view
+- (CGRect) contentFrame {
+ CGRect frame = self.contentView.frame;
+ frame.origin.x = 0;
+ frame.origin.y = (self.showToolbar && !self.positionToolbarOnBottom) ? 44 : 0;
+ return frame;
+}
+
+// frame of the content view + toolbar
+- (CGRect) bodyFrame {
+ CGRect frame = bodyView.frame;
+ frame.size = self.contentView.frame.size;
+ if(self.showToolbar) frame.size.height += 44;
+ return frame;
+}
+
+- (void) slideIntoView:(UIView *)wrapper
+{
+ self.containerView = wrapper;
+
+ if(self.avoidKeyboard) {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:)
+ name:UIKeyboardWillShowNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:)
+ name:UIKeyboardWillHideNotification object:nil];
+ }
+
+ if(self.contentView.frame.size.width < self.containerView.frame.size.width) {
+ bodyView.backgroundColor = [UIColor blackColor];
+ bodyView.clipsToBounds = YES;
+ bodyView.layer.cornerRadius = 5;
+ }
+
+ //set initial location at bottom of view
+ CGRect frame = self.frame;
+ frame.size = wrapper.frame.size;
+ frame.origin = CGPointMake(0, 0);
+ self.frame = frame;
+
+ self.contentView.frame = [self contentFrame];
+
+ frame = [self bodyFrame];
+ frame.origin = [self offScreenCoordinates];
+ bodyView.frame = frame;
+
+ if(self.showToolbar) [self drawToolbar];
+
+ [wrapper addSubview:self];
+ [bodyView addSubview:self.contentView];
+
+ // slide in animation
+ [UIView beginAnimations:@"slideIn" context:nil];
+ [UIView setAnimationDelegate:self];
+
+ frame.origin = [self onScreenCoordinates];
+ bodyView.frame = frame;
+ self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.55];
+
+ [UIView commitAnimations];
+
+ framePriorToKeyboardMovement = bodyView.frame;
+}
+
+- (void) slideOut
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [UIView beginAnimations:@"slideOut" context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+
+ CGRect frame = bodyView.frame;
+ frame.origin = [self offScreenCoordinates];
+ bodyView.frame = frame;
+ self.backgroundColor = [UIColor clearColor];
+
+ [UIView commitAnimations];
+}
+
+- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
+{
+ if ([animationID isEqualToString:@"slideOut"]) {
+ if(self.superview) [self removeFromSuperview];
+ } else if ([animationID isEqualToString:@"slideIn"]) {
+
+ }
+}
+
+- (void) cancelPressed:(id)sender {
+ if(self.cancelBlock) self.cancelBlock();
+ else [self slideOut];
+}
+
+- (void) donePressed:(id)sender {
+ if(self.doneBlock) self.doneBlock();
+ else [self slideOut];
+}
+
+// Search recursively for first responder
+- (UIView*)findFirstResponderBeneathView:(UIView*)view {
+ for ( UIView *childView in view.subviews ) {
+ if ([childView respondsToSelector:@selector(isFirstResponder)]
+ && [childView isFirstResponder] ) return childView;
+ UIView *result = [self findFirstResponderBeneathView:childView];
+ if (result) return result;
+ }
+ return nil;
+}
+
+- (BOOL) adjustToFirstResponder {
+ UIView *firstResponder = [self findFirstResponderBeneathView:self];
+ if (!firstResponder) return NO;
+
+ CGRect firstResponderBounds = [firstResponder convertRect:CGRectZero toView:bodyView];
+ CGFloat idealPosition = 70;
+
+ CGRect frame = bodyView.frame;
+ frame.origin.y = idealPosition - firstResponderBounds.origin.y;
+
+ // Shrink view's height by the keyboard's height, and scroll to show the text field/view being edited
+ [UIView beginAnimations:nil context:NULL];
+ bodyView.frame = frame;
+ [UIView commitAnimations];
+ return YES;
+}
+
+
+- (void)keyboardWillShow:(NSNotification*)notification {
+ UIView *firstResponder = [self findFirstResponderBeneathView:self];
+ if (!firstResponder) return;
+
+ framePriorToKeyboardMovement = bodyView.frame;
+
+ // Use this view's coordinate system
+ CGRect keyboardBounds = [self convertRect:[[[notification userInfo]
+ objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]
+ fromView:nil];
+ CGRect firstResponderBounds = [self convertRect:firstResponder.bounds fromView:firstResponder];
+ CGFloat idealPosition = self.frame.size.height - keyboardBounds.size.height - firstResponder.frame.size.height - 30;
+ if(firstResponderBounds.origin.y <= idealPosition) return;
+
+ CGRect frame = bodyView.frame;
+ frame.origin.y -= firstResponderBounds.origin.y - idealPosition;
+
+ CGFloat animationDuration = [[[notification userInfo]
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
+ NSInteger animationCurve = [[[notification userInfo]
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
+
+ // Shrink view's height by the keyboard's height, and scroll to show the text field/view being edited
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationCurve:animationCurve];
+ [UIView setAnimationDuration:animationDuration];
+
+ bodyView.frame = frame;
+
+ [UIView commitAnimations];
+}
+
+- (void)keyboardWillHide:(NSNotification*)notification {
+ CGFloat animationDuration = [[[notification userInfo]
+ objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
+ NSInteger animationCurve = [[[notification userInfo]
+ objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
+
+ // Restore dimensions to prior size
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationCurve:animationCurve];
+ [UIView setAnimationDuration:animationDuration];
+
+ bodyView.frame = framePriorToKeyboardMovement;
+
+ [UIView commitAnimations];
+}
+
+-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ for (UITouch *touch in touches) {
+ if (CGRectContainsPoint(bodyView.frame, [touch locationInView:self])) return;
+ }
+
+ if((self.options & CancelOnBackgroundPressed) == CancelOnBackgroundPressed) {
+ [self cancelPressed:nil];
+ }
+}
+
+@end
View
45 MFSlidingViewDemo/MFSlidingViewDemo-Info.plist
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.mikefrederick.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
View
14 MFSlidingViewDemo/MFSlidingViewDemo-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'MFSlidingViewDemo' target in the 'MFSlidingViewDemo' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_4_0
+#warning "This project uses features only available in iOS SDK 4.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
View
0  MFSlidingViewDemo/README
No changes.
View
382 MFSlidingViewDemo/en.lproj/DemoViewController.xib
@@ -0,0 +1,382 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1296</int>
+ <string key="IBDocument.SystemVersion">11D50b</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
+ <string key="IBDocument.AppKitVersion">1138.32</string>
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">1181</string>
+ </object>
+ <array key="IBDocument.IntegratedClassDependencies">
+ <string>IBUITextField</string>
+ <string>IBUIButton</string>
+ <string>IBUIView</string>
+ <string>IBUILabel</string>
+ <string>IBProxyObject</string>
+ </array>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBProxyObject" id="843779117">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="774585933">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">274</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="IBUIButton" id="80186642">
+ <reference key="NSNextResponder" ref="774585933"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{20, 211}, {280, 37}}</string>
+ <reference key="NSSuperview" ref="774585933"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">Press Me For Demos</string>
+ <object class="NSColor" key="IBUIHighlightedTitleColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
+ <int key="type">2</int>
+ <double key="pointSize">15</double>
+ </object>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">Helvetica-Bold</string>
+ <double key="NSSize">15</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{0, 20}, {320, 460}}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="80186642"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC43NQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace" id="942792311">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="298456491">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">292</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="IBUILabel" id="70295048">
+ <reference key="NSNextResponder" ref="298456491"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{14, 74}, {266, 21}}</string>
+ <reference key="NSSuperview" ref="298456491"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <int key="IBUIContentMode">7</int>
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <string key="IBUIText">This is just a random view!</string>
+ <object class="NSColor" key="IBUITextColor" id="634370984">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
+ </object>
+ <nil key="IBUIHighlightedColor"/>
+ <int key="IBUIBaselineAdjustment">0</int>
+ <float key="IBUIMinimumFontSize">10</float>
+ <int key="IBUITextAlignment">1</int>
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="403106703">
+ <int key="type">1</int>
+ <double key="pointSize">17</double>
+ </object>
+ <object class="NSFont" key="IBUIFont" id="813916990">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">17</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrameSize">{300, 280}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="70295048"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xODAzOTIxNTY5IDAuNTQ1MDk4MDM5MiAwLjg5MDE5NjA3ODQAA</bytes>
+ </object>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="29823670">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">292</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="IBUILabel" id="498850305">
+ <reference key="NSNextResponder" ref="29823670"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{14, 8}, {266, 21}}</string>
+ <reference key="NSSuperview" ref="29823670"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="529917611"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <int key="IBUIContentMode">7</int>
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <string key="IBUIText">I will avoid the keyboard!</string>
+ <reference key="IBUITextColor" ref="634370984"/>
+ <nil key="IBUIHighlightedColor"/>
+ <int key="IBUIBaselineAdjustment">0</int>
+ <float key="IBUIMinimumFontSize">10</float>
+ <int key="IBUITextAlignment">1</int>
+ <reference key="IBUIFontDescription" ref="403106703"/>
+ <reference key="IBUIFont" ref="813916990"/>
+ </object>
+ <object class="IBUITextField" id="529917611">
+ <reference key="NSNextResponder" ref="29823670"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{20, 50}, {260, 31}}</string>
+ <reference key="NSSuperview" ref="29823670"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUIText"/>
+ <int key="IBUIBorderStyle">3</int>
+ <string key="IBUIPlaceholder">Click on me!</string>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ <reference key="NSCustomColorSpace" ref="942792311"/>
+ </object>
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+ <float key="IBUIMinimumFontSize">17</float>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
+ <int key="type">1</int>
+ <double key="pointSize">14</double>
+ </object>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">14</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrameSize">{320, 214}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="498850305"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+ </object>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="774585933"/>
+ </object>
+ <int key="connectionID">7</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view1</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="298456491"/>
+ </object>
+ <int key="connectionID">12</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view2</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="29823670"/>
+ </object>
+ <int key="connectionID">15</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">buttonPressed:</string>
+ <reference key="source" ref="80186642"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">9</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="843779117"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6</int>
+ <reference key="object" ref="774585933"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="80186642"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">8</int>
+ <reference key="object" ref="80186642"/>
+ <reference key="parent" ref="774585933"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">10</int>
+ <reference key="object" ref="298456491"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="70295048"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">11</int>
+ <reference key="object" ref="70295048"/>
+ <reference key="parent" ref="298456491"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">13</int>
+ <reference key="object" ref="29823670"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="498850305"/>
+ <reference ref="529917611"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">14</int>
+ <reference key="object" ref="498850305"/>
+ <reference key="parent" ref="29823670"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">16</int>
+ <reference key="object" ref="529917611"/>
+ <reference key="parent" ref="29823670"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-1.CustomClassName">DemoViewController</string>
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="-2.CustomClassName">UIResponder</string>
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="16.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">16</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">DemoViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">buttonPressed:</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <string key="NS.key.0">buttonPressed:</string>
+ <object class="IBActionInfo" key="NS.object.0">
+ <string key="name">buttonPressed:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
+ <dictionary class="NSMutableDictionary" key="outlets">
+ <string key="view1">UIView</string>
+ <string key="view2">UIView</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="view1">
+ <string key="name">view1</string>
+ <string key="candidateClassName">UIView</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="view2">
+ <string key="name">view2</string>
+ <string key="candidateClassName">UIView</string>
+ </object>
+ </dictionary>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/DemoViewController.h</string>
+ </object>
+ </object>
+ </array>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <real value="1296" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">1181</string>
+ </data>
+</archive>
View
2  MFSlidingViewDemo/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
18 MFSlidingViewDemo/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// MFSlidingViewDemo
+//
+// Created by Michael Frederick on 5/3/12.
+// Copyright (c) 2012 University of Wisconsin - Madison. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "MFAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([MFAppDelegate class]));
+ }
+}
View
42 README
@@ -0,0 +1,42 @@
+MFSlidingView
+================
+Sometimes it's nice to be able to present a nice overlay view without having to present a whole new view controller. MFSlidingView helps animate views on top of your current view.
+
+Screenshots
+==========
+![image](http://i.imgur.com/Y8NHq.png)
+
+Features
+==========
+* Ability to easily configure the start and stop positions of the sliding animation (i.e. slide a view from below the screen to the middle of the screen, or from above the screen to the top of the screen).
+* Option to display a toolbar above or below your view.
+* Option to display a title, cancel button, and/or done button on the toolbar.
+* Option to dismiss the view when the background is pressed.
+* Option to perform keyboard avoidance for UITextFields and UITextViews.
+* Usage of blocks for dismissal actions.
+
+
+Usage
+==========
+
+###Minimum Configuration
+ [MFSlidingView slideView:[[[UIDatePicker alloc] init] autorelease] intoView:self.view
+ onScreenPosition:BottomOfScreen];
+
+###Medium Configuration
+ [MFSlidingView slideView:viewToSlideIn intoView:viewToSlideInTo
+ onScreenPosition:MiddleOfScreen offScreenPosition:LeftOfScreen];
+
+###Full Configuration
+ SlidingViewOptions options = ShowDoneButton|ShowCancelButton|CancelOnBackgroundPressed|AvoidKeyboard;
+ void (^cancelOrDoneBlock)() = ^{
+ // we must manually slide out the view out if we specify this block
+ [MFSlidingView slideOut];
+ };
+
+ [MFSlidingView slideView:viewToSlideIn intoView:self.view
+ onScreenPosition:BottomOfScreen
+ offScreenPosition:BelowScreen title:@"Avoid Keyboard"
+ options:options
+ doneBlock:cancelOrDoneBlock
+ cancelBlock:cancelOrDoneBlock];
Please sign in to comment.
Something went wrong with that request. Please try again.