UIView换UIImage

来源:互联网 发布:淘宝淘抢购 编辑:程序博客网 时间:2024/06/06 04:07

// 把一个View视图转换为Image-(UIImage *)getImageFromView{    UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 44)];    redView.backgroundColor = [UIColor redColor];    //UIGraphicsBeginImageContext(theView.bounds.size);        UIGraphicsBeginImageContextWithOptions(redView.bounds.size, YES, redView.layer.contentsScale);        [redView.layer renderInContext:UIGraphicsGetCurrentContext()];        UIImage *image=UIGraphicsGetImageFromCurrentImageContext();        UIGraphicsEndImageContext();        return image;    }


0 0
原创粉丝点击