8
내용이 이미지 인 하위 레이어가있는보기가 있습니다.보기의 레이어에서 UIImage 가져 오기?
myView.image로 뷰의 이미지를 가져오고 싶지만 뷰에는 이미지 레이어가 없습니다.
뷰의 레이어에서 UIImage를 만드는 방법은 무엇입니까?
내용이 이미지 인 하위 레이어가있는보기가 있습니다.보기의 레이어에서 UIImage 가져 오기?
myView.image로 뷰의 이미지를 가져오고 싶지만 뷰에는 이미지 레이어가 없습니다.
뷰의 레이어에서 UIImage를 만드는 방법은 무엇입니까?
UIGraphicsBeginImageContext(yourView.bounds.size);
[yourView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
참고 : QuartzCore를 포함시켜야합니다.
CGRect myRect =CGRectMake(0, 0, 300, 300);// [self.view bounds];
UIGraphicsBeginImageContext(myRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, myRect);
[self.view.layer renderInContext:ctx];
UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();