iPhone objective c 截屏代碼

字號:


    objective c 截屏代碼
    -(void)save{
    UIGraphicsBeginImageContext(mybackgroundview.bounds.size); //currentView 當(dāng)前的view
    [mybackgroundview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
    }截取 您想要的一層
    UIGraphicsBeginImageContext(CGSizeMake(320, 300)); //currentView 當(dāng)前的view
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
    截取自定義的大小
    剛剛用到 不知道 是不是您想要的