想要创建一个内部有一个透明框架的视图,以便透过这个透明框架可以看到视图背后的视图,但是在这之外的区域不会透视。所以基本上是视图中的一个窗口。在UIView中切透明洞
希望能够做这样的事情:
CGRect hole = CGRectMake(100, 100, 250, 250);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
CGContextFillRect(context, rect);
CGContextAddRect(context, hole);
CGContextClip(context);
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
但明确不会覆盖黑色,所以整个背景是黑色的。任何想法沿着这些线?
2017年死简易的解决方案http:// stackoverflow。com/q/42330283/294884 – Fattie 2017-02-19 18:15:27