iOS 如何在一个页面抠出一个圆

来源:互联网 发布:淘宝中国知网上查重 编辑:程序博客网 时间:2024/04/30 00:40

下面这个方法是用CALayer绘制的代理方法



- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx

{


    //图形上下文形变,解决图片倒立的问题

//    CGContextScaleCTM(ctx, 1, -1);

//    CGContextTranslateCTM(ctx, 0, -667);

    CGRect rect1 =CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height);

    CGContextSetFillColorWithColor(ctx, [UIColorgrayColor].CGColor);

       CGContextAddRect(ctx, rect1);

    CGContextDrawPath(ctx,kCGPathFill);

    

    

    CGRect rect=CGRectMake(200,10, 200, 200);

    CGContextAddEllipseInRect(ctx, rect);

    //关键是这句..

    CGContextSetBlendMode(ctx,kCGBlendModeClear);

    CGContextFillPath(ctx);

 }


0 0
原创粉丝点击