寫了一個類似魔獸小地圖功能的控制項。
比如你有一個可以放大縮小的scrollView。會在裡面進行一些放大縮小,點擊裡面的按鈕呀,等操作。
這個小地圖控制項。就會和你的大scrollView同步。並有縮圖和你當前視口的位置。就像遊戲裡那樣。
看圖。
SmallMapView.h
<UIKit/UIKit.h> <QuartzCore/QuartzCore.h>@property (nonatomic,assign,)@property (nonatomic,retain,)CALayer *@property (nonatomic,retain,)CALayer *@property (nonatomic,retain,)UIScrollView *- ()initWithUIScrollView:(UIScrollView *- ()scrollViewDidScroll:(UIScrollView *- (
SmallMapView.m
- ()initWithUIScrollView:(UIScrollView *== _contentLayer = _rectangleLayer == = CGSizeMake(, = == == CGRectMake(, , scrollView.frame.size.width * _scaling, scrollView.frame.size.height *- (- ()scrollViewDidScroll:(UIScrollView * x = y = h = w =* _scaling, y * _scaling, h * self.scaling, w *- (=- ()setScaling:(UIScrollView *= self.frame.size.height /- (CALayer *)drawContentView:(UIScrollView **layer == (UIView *view *image =*copyLayer == ( x = y = h = w == CGRectMake(x * _scaling,y *_scaling,w * _scaling,h *
如果有需要的,可以去這裡得到源碼:https://github.com/TinyQ/LittleMapView.git