萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> ios >> iPhone objective c 截屏代碼

iPhone objective c 截屏代碼

   objective c 截屏代碼

  -(void)save{

  UIGraphicsBeginImageContext(mybackgroundview.bounds.size); //currentView 當前的view

  [mybackgroundview.layer renderInContext:UIGraphicsGetCurrentContext()];

  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

  }截取 您想要的一層

  UIGraphicsBeginImageContext(CGSizeMake(320, 300)); //currentView 當前的view

  [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

  截取自定義的大小

  剛剛用到 不知道 是不是您想要的

copyright © 萬盛學電腦網 all rights reserved