경계선이있는 UIImage를 성공적으로 다시 그리지 만 테두리 + 그림자는 다시 그리지 못했습니다. 아래의 코드는 이미지를 흰색 테두리로 성공적으로 그립니다. 그러나 테두리 아래에 그림자를 포함하는 방법을 알아낼 수 없습니다. 도움이 대단히 감사합니다!UIImage에 테두리 및 그림자 그리기
- (UIImage *)generatePhotoFrameWithImage:(UIImage *)image {
CGSize newSize = CGSizeMake(image.size.width + 50, image.size.height + 60);
UIGraphicsBeginImageContext(newSize);
CGRect rect = CGRectMake(25, 35, image.size.width, image.size.height);
[image drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextStrokeRectWithWidth(context, CGRectMake(25, 35, image.size.width, image.size.height), 50);
//CGContextSetShadowWithColor(context, CGSizeMake(0, -60), 5, [UIColor blackColor].CGColor);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result; }
추 신 : 전체 이미지 품질을 유지해야하기 때문에 UIImageView를 사용하지 않습니다.
'UIImageView'는 어떤 점에서 이미지 품질을 잃게됩니까? –
그림자/테두리를 적용한 후 이미지를 파일로 출력 할 수 있어야했습니다. UIImageView를 PNG/BMP로 렌더링 할 수 있지만 UIImageView의 크기 만 나오게됩니다. – thedeveloper3124