指定上下文中可显示区域

    xiaoxiao2021-04-15  33

    图形上下文–裁剪

    - (void)drawRect:(CGRect)rect { //画圆:以便以后指定可以显示内容的范围 CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddEllipseInRect(ctx, CGRectMake(100, 100, 200, 200)); //指定上下文中可以显示内容的范围:该方法一定要在绘制图形之前调用 CGContextClip(ctx); CGContextStrokePath(ctx); UIImage *image = [UIImage imageNamed:@"timg.jpg"]; //按照原始大小绘制图片 [image drawAtPoint:CGPointMake(100, 100)]; }
    转载请注明原文地址: https://ju.6miu.com/read-671360.html

    最新回复(0)