Skip to content

Commit

Permalink
Added Map snapshot sample and a custom transition
Browse files Browse the repository at this point in the history
  • Loading branch information
shu223 committed Sep 24, 2013
1 parent f005965 commit 3fbc0e6
Show file tree
Hide file tree
Showing 17 changed files with 1,163 additions and 6 deletions.
48 changes: 48 additions & 0 deletions iOS7Sampler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
8A043B1817F0D34200DA84E9 /* Map3DViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A043B1617F0D34200DA84E9 /* Map3DViewController.m */; };
8A043B1917F0D34200DA84E9 /* Map3DViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A043B1717F0D34200DA84E9 /* Map3DViewController.xib */; };
8A043B1B17F0D3D600DA84E9 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A043B1A17F0D3D600DA84E9 /* MapKit.framework */; };
8A43D5B117F11BCA005E8BE8 /* MapSnapshotViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A43D5AF17F11BCA005E8BE8 /* MapSnapshotViewController.m */; };
8A43D5B217F11BCA005E8BE8 /* MapSnapshotViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A43D5B017F11BCA005E8BE8 /* MapSnapshotViewController.xib */; };
8A43D5B717F11E72005E8BE8 /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8A43D5B417F11E72005E8BE8 /* SVProgressHUD.bundle */; };
8A43D5B817F11E72005E8BE8 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A43D5B617F11E72005E8BE8 /* SVProgressHUD.m */; };
8A43D5D417F12307005E8BE8 /* ZBFallenBricksAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A43D5C917F12307005E8BE8 /* ZBFallenBricksAnimator.m */; };
8A43D5D817F12397005E8BE8 /* UIViewController+Animator.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A43D5D717F12397005E8BE8 /* UIViewController+Animator.m */; };
8A7BF1C117ED384C004EF216 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A7BF1C017ED384C004EF216 /* Foundation.framework */; };
8A7BF1C317ED384C004EF216 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A7BF1C217ED384C004EF216 /* CoreGraphics.framework */; };
8A7BF1C517ED384C004EF216 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A7BF1C417ED384C004EF216 /* UIKit.framework */; };
Expand Down Expand Up @@ -107,6 +113,16 @@
8A043B1617F0D34200DA84E9 /* Map3DViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Map3DViewController.m; sourceTree = "<group>"; };
8A043B1717F0D34200DA84E9 /* Map3DViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Map3DViewController.xib; sourceTree = "<group>"; };
8A043B1A17F0D3D600DA84E9 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
8A43D5AE17F11BCA005E8BE8 /* MapSnapshotViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapSnapshotViewController.h; sourceTree = "<group>"; };
8A43D5AF17F11BCA005E8BE8 /* MapSnapshotViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapSnapshotViewController.m; sourceTree = "<group>"; };
8A43D5B017F11BCA005E8BE8 /* MapSnapshotViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MapSnapshotViewController.xib; sourceTree = "<group>"; };
8A43D5B417F11E72005E8BE8 /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
8A43D5B517F11E72005E8BE8 /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
8A43D5B617F11E72005E8BE8 /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
8A43D5C817F12307005E8BE8 /* ZBFallenBricksAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZBFallenBricksAnimator.h; sourceTree = "<group>"; };
8A43D5C917F12307005E8BE8 /* ZBFallenBricksAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZBFallenBricksAnimator.m; sourceTree = "<group>"; };
8A43D5D617F12397005E8BE8 /* UIViewController+Animator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Animator.h"; sourceTree = "<group>"; };
8A43D5D717F12397005E8BE8 /* UIViewController+Animator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+Animator.m"; sourceTree = "<group>"; };
8A7BF1BD17ED384B004EF216 /* iOS7Sampler.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS7Sampler.app; sourceTree = BUILT_PRODUCTS_DIR; };
8A7BF1C017ED384C004EF216 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8A7BF1C217ED384C004EF216 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -230,6 +246,27 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
8A43D5B317F11E72005E8BE8 /* SVProgressHUD */ = {
isa = PBXGroup;
children = (
8A43D5B417F11E72005E8BE8 /* SVProgressHUD.bundle */,
8A43D5B517F11E72005E8BE8 /* SVProgressHUD.h */,
8A43D5B617F11E72005E8BE8 /* SVProgressHUD.m */,
);
path = SVProgressHUD;
sourceTree = "<group>";
};
8A43D5B917F12307005E8BE8 /* ZBCustomTransitions */ = {
isa = PBXGroup;
children = (
8A43D5D617F12397005E8BE8 /* UIViewController+Animator.h */,
8A43D5D717F12397005E8BE8 /* UIViewController+Animator.m */,
8A43D5C817F12307005E8BE8 /* ZBFallenBricksAnimator.h */,
8A43D5C917F12307005E8BE8 /* ZBFallenBricksAnimator.m */,
);
path = ZBCustomTransitions;
sourceTree = "<group>";
};
8A7BF1B417ED384B004EF216 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -331,6 +368,9 @@
8A043B1517F0D34200DA84E9 /* Map3DViewController.h */,
8A043B1617F0D34200DA84E9 /* Map3DViewController.m */,
8A043B1717F0D34200DA84E9 /* Map3DViewController.xib */,
8A43D5AE17F11BCA005E8BE8 /* MapSnapshotViewController.h */,
8A43D5AF17F11BCA005E8BE8 /* MapSnapshotViewController.m */,
8A43D5B017F11BCA005E8BE8 /* MapSnapshotViewController.xib */,
);
path = SampleViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -403,6 +443,8 @@
8A7BF3B117ED8B43004EF216 /* vendor */ = {
isa = PBXGroup;
children = (
8A43D5B917F12307005E8BE8 /* ZBCustomTransitions */,
8A43D5B317F11E72005E8BE8 /* SVProgressHUD */,
8A7BF3B217ED8B43004EF216 /* HUAnimator */,
);
path = vendor;
Expand Down Expand Up @@ -508,6 +550,7 @@
8A7BF3A417ED7F5D004EF216 /* stage_3@2x.png in Resources */,
8A7BF3A817ED7F5D004EF216 /* stage_7@2x.png in Resources */,
8A7BF37017ED5BB1004EF216 /* m20@2x.png in Resources */,
8A43D5B717F11E72005E8BE8 /* SVProgressHUD.bundle in Resources */,
8A7BF35E17ED5BB1004EF216 /* m1@2x.png in Resources */,
8A7BF35F17ED5BB1004EF216 /* m2@2x.png in Resources */,
8A7BF37517ED5BB1004EF216 /* m25@2x.png in Resources */,
Expand Down Expand Up @@ -558,6 +601,7 @@
8A7BF37817ED5BB1004EF216 /* m28@2x.png in Resources */,
8A7BF37917ED5BB1004EF216 /* m29@2x.png in Resources */,
8A7BF3AA17ED7F5D004EF216 /* stage_9@2x.png in Resources */,
8A43D5B217F11BCA005E8BE8 /* MapSnapshotViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -578,16 +622,20 @@
files = (
8A7BF1D117ED384C004EF216 /* AppDelegate.m in Sources */,
8A7BF39417ED7EF7004EF216 /* MotionEffectViewController.m in Sources */,
8A43D5B117F11BCA005E8BE8 /* MapSnapshotViewController.m in Sources */,
8A7BF3BB17ED8B43004EF216 /* HUTransitionAnimator.m in Sources */,
8A7BF38817ED6882004EF216 /* ActivityTypesViewController.m in Sources */,
8A7BF3AF17ED8A9E004EF216 /* CustomTransitionViewController.m in Sources */,
8A7BF1D717ED384C004EF216 /* MasterViewController.m in Sources */,
8A7BF1CD17ED384C004EF216 /* main.m in Sources */,
8A7BF29217ED4C9F004EF216 /* DynamicBehaviorsViewController.m in Sources */,
8A43D5B817F11E72005E8BE8 /* SVProgressHUD.m in Sources */,
8A43D5D417F12307005E8BE8 /* ZBFallenBricksAnimator.m in Sources */,
8A043B1817F0D34200DA84E9 /* Map3DViewController.m in Sources */,
8A7BF3BD17ED8B43004EF216 /* HUTransitionHorizontalLinesAnimator.m in Sources */,
8A7BF3BC17ED8B43004EF216 /* HUTransitionGhostAnimator.m in Sources */,
8A7BF38D17ED7897004EF216 /* SpeechSynthesisViewController.m in Sources */,
8A43D5D817F12397005E8BE8 /* UIViewController+Animator.m in Sources */,
8A7BF1DA17ED384C004EF216 /* DetailViewController.m in Sources */,
8A7BF3BE17ED8B43004EF216 /* HUTransitionVerticalLinesAnimator.m in Sources */,
);
Expand Down
6 changes: 5 additions & 1 deletion iOS7Sampler/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ - (void)viewDidLoad
kItemKeyClassPrefix: @"ActivityTypes",
},

// ...
// Static Map Snapshots
@{kItemKeyTitle: @"Static Map Snapshots",
kItemKeyDescription: @"Creating a snapshot with MKMapSnapshotOptions, MKMapSnapshotter.",
kItemKeyClassPrefix: @"MapSnapshot",
},
];
}

Expand Down
15 changes: 12 additions & 3 deletions iOS7Sampler/SampleViewControllers/CustomTransitionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

#import "CustomTransitionViewController.h"
#import "HUTransitionAnimator.h"
#import "ZBFallenBricksAnimator.h"


typedef enum {
TransitionTypeNormal,
TransitionTypeVerticalLines,
TransitionTypeHorizontalLines,
TransitionTypeGravity,
} TransitionType;


Expand Down Expand Up @@ -60,21 +62,24 @@ - (void)didReceiveMemoryWarning
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
HUTransitionAnimator *animator;
NSObject <UIViewControllerAnimatedTransitioning> *animator;

switch (type) {
case TransitionTypeVerticalLines:
animator = [[HUTransitionVerticalLinesAnimator alloc] init];
[(HUTransitionAnimator *)animator setPresenting:NO];
break;
case TransitionTypeHorizontalLines:
animator = [[HUTransitionHorizontalLinesAnimator alloc] init];
[(HUTransitionAnimator *)animator setPresenting:NO];
break;
case TransitionTypeGravity:
animator = [[ZBFallenBricksAnimator alloc] init];
break;
default:
animator = nil;
}

animator.presenting = (operation == UINavigationControllerOperationPop) ? NO : YES;

return animator;
}

Expand All @@ -92,6 +97,10 @@ - (IBAction)pop:(UIButton *)sender {
case 1:
type = TransitionTypeHorizontalLines;
break;

case 2:
type = TransitionTypeGravity;
break;
}

[self.navigationController popViewControllerAnimated:YES];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<autoresizingMask key="autoresizingMask"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8G5-im-Cpz">
<rect key="frame" x="34" y="92" width="240" height="40"/>
<rect key="frame" x="34" y="59" width="240" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Pop with Vertical Lines">
Expand All @@ -30,7 +30,7 @@
</connections>
</button>
<button opaque="NO" tag="1" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VDE-63-BGD">
<rect key="frame" x="34" y="140" width="240" height="40"/>
<rect key="frame" x="34" y="103" width="240" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Pop with Holizontal Lines">
Expand All @@ -40,6 +40,17 @@
<action selector="pop:" destination="-1" eventType="touchUpInside" id="hId-OX-w2U"/>
</connections>
</button>
<button opaque="NO" tag="2" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a2C-lD-RlQ">
<rect key="frame" x="34" y="147" width="240" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Pop with Gravity">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="pop:" destination="-1" eventType="touchUpInside" id="0TR-8K-QRv"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
Expand Down
13 changes: 13 additions & 0 deletions iOS7Sampler/SampleViewControllers/MapSnapshotViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// MapSnapshotViewController.h
// iOS7Sampler
//
// Created by shuichi on 9/24/13.
// Copyright (c) 2013 Shuichi Tsutsumi. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MapSnapshotViewController : UIViewController

@end
80 changes: 80 additions & 0 deletions iOS7Sampler/SampleViewControllers/MapSnapshotViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// MapSnapshotViewController.m
// iOS7Sampler
//
// Created by shuichi on 9/24/13.
// Copyright (c) 2013 Shuichi Tsutsumi. All rights reserved.
//

#import "MapSnapshotViewController.h"
#import <MapKit/MapKit.h>
#import "SVProgressHUD.h"


@interface MapSnapshotViewController ()
@property (nonatomic, weak) IBOutlet MKMapView *mapView;
@property (nonatomic, weak) IBOutlet UIImageView *imageView;
@end


@implementation MapSnapshotViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];

// map setup
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(37.78275123, -122.40416442);
self.mapView.camera.altitude = 200;
self.mapView.camera.pitch = 70;
self.mapView.showsBuildings = YES;

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


// =============================================================================
#pragma mark - IBAction

- (IBAction)createSnapshot {

[SVProgressHUD showWithStatus:@"Creating a screenshot..."
maskType:SVProgressHUDMaskTypeGradient];

MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
options.size = CGSizeMake(512, 512);
options.scale = [[UIScreen mainScreen] scale];
options.camera = self.mapView.camera;
options.mapType = MKMapTypeStandard;

MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];

[snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *e)
{
if (e) {
NSLog(@"error:%@", e);
}
else {

[SVProgressHUD showSuccessWithStatus:@"done!"];

self.imageView.image = snapshot.image;
}
}];
}

@end
43 changes: 43 additions & 0 deletions iOS7Sampler/SampleViewControllers/MapSnapshotViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapSnapshotViewController">
<connections>
<outlet property="imageView" destination="9e3-N3-cSW" id="Hbc-Fb-zdW"/>
<outlet property="mapView" destination="hmx-hx-NyE" id="rsn-Fi-933"/>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="hmx-hx-NyE">
<rect key="frame" x="0.0" y="0.0" width="320" height="283"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</mapView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tPu-WF-e80">
<rect key="frame" x="0.0" y="291" width="320" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Create a snapshot">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="createSnapshot" destination="-1" eventType="touchUpInside" id="mV0-g8-4kc"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9e3-N3-cSW">
<rect key="frame" x="40" y="420" width="240" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>
Binary file added vendor/SVProgressHUD/SVProgressHUD.bundle/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3fbc0e6

Please sign in to comment.