Created
August 24, 2013 14:22
-
-
Save wagyu298/6328430 to your computer and use it in GitHub Desktop.
1/30秒に1ピクセルMKMapViewを右にスクロールさせるサンプル
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
#import <MapKit/MapKit.h> | |
#import "ViewController.h" | |
@interface ViewController () | |
@property (weak, nonatomic) IBOutlet MKMapView *mapView; | |
@property (strong, nonatomic) NSTimer *timer; | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
_timer = [NSTimer scheduledTimerWithTimeInterval:1.0/30.0 target:self selector:@selector(tick) userInfo:nil repeats:YES]; | |
} | |
- (void)tick | |
{ | |
CGPoint point = _mapView.center; | |
UIScreen *screen = [UIScreen mainScreen]; | |
point.x += 1.0f / screen.scale; | |
CLLocationCoordinate2D center = [_mapView convertPoint:point toCoordinateFromView:_mapView]; | |
[_mapView setCenterCoordinate:center]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment