Ben*_*ieb 16
我们在填字游戏中这样做.在drawRect方法中,屏蔽圆圈(使用包含放大镜"遮罩"的单色位图)并使用2x缩放变换在其中绘制主题视图.然后在上面画一个放大镜图像,你就完成了.
- (void) drawRect: (CGRect) rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect bounds = self.bounds;
CGImageRef mask = [UIImage imageNamed: @"loupeMask"].CGImage;
UIImage *glass = [UIImage imageNamed: @"loupeImage"];
CGContextSaveGState(context);
CGContextClipToMask(context, bounds, mask);
CGContextFillRect(context, bounds);
CGContextScaleCTM(context, 2.0, 2.0);
//draw your subject view here
CGContextRestoreGState(context);
[glass drawInRect: bounds];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6868 次 |
| 最近记录: |