UIView放大镜
@interface MagnifierView : UIView{ } @property (nonatomic, retain) UIView *viewToMagnify; @property (nonatomic, assign) CGPoint touchPoint; @end
@implementation MagnifierView - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:CGRectMake(0, 0, 320, 35)]) { // make the circle-shape outline with a nice border. self.layer.borderColor = [[UIColor lightGrayColor] CGColor]; self.layer.borderWidth = 0.5; self.layer.cornerRadius = 17; self.layer.masksToBounds = YES; } return self; } - (void)setTouchPoint:(CGPoint)pt { _touchPoint = pt; self.center = CGPointMake(pt.x, pt.y); } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context,1*(self.frame.size.width*0.5),1*(self.frame.size.height*0.5)); CGContextScaleCTM(context, 1.5, 1.5); CGContextTranslateCTM(context,-1*(_touchPoint.x),-1*(_touchPoint.y)); [self.viewToMagnify.layer renderInContext:context]; } - (void)dealloc { self.viewToMagnify=nil; // [super dealloc]; } @end
里面有坐标旋转和图层复制

浙公网安备 33010602011771号