Skip to content

Instantly share code, notes, and snippets.

@wagyu298
Created August 24, 2013 14:22
Show Gist options
  • Save wagyu298/6328430 to your computer and use it in GitHub Desktop.
Save wagyu298/6328430 to your computer and use it in GitHub Desktop.
1/30秒に1ピクセルMKMapViewを右にスクロールさせるサンプル
#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