forked from shu223/iOS7-Sampler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Map snapshot sample and a custom transition
- Loading branch information
Showing
17 changed files
with
1,163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
iOS7Sampler/SampleViewControllers/MapSnapshotViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
80
iOS7Sampler/SampleViewControllers/MapSnapshotViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
iOS7Sampler/SampleViewControllers/MapSnapshotViewController.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
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.
Oops, something went wrong.