iOS 截屏代码的实现

iOS开发中难免会有PM说要再项目中,实现截屏,还分享出去,这里就把截屏的代码贴出来。

分享的话,就相当于只是把这种截屏的图片保存起来,到时候,分享的时候,把图片传过去

 

#import <QuartzCore/QuartzCore.h>

添加QuartzCore.framework库

-(void) screenShotAction
{
    UIGraphicsBeginImageContext(self.bounds.size);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    UIImageView *imaView = [[UIImageView alloc] initWithImage:image];
    imaView.frame = CGRectMake(0, 0, 500, 500);
    [self addSubview:imaView];

//写入相册
    UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值