Вы должны связать Список ошибок в ResponseEntity и затем вернуть его.
@ExceptionHandler(CustomException.class)
public ResponseEntity> validationExceptionHandler(CustomException exception) {
List list = new ArrayList<>();
ErrorOutDTO error = new ErrorOutDTO();
error.setField(exception.getField());
error.setMessage(exception.getMessage());
list.add(error);
return (ResponseEntity>)new ResponseEntity(list, HttpStatus.CONFLICT);
}
Скажем, у Вас есть a CGImageRef
для изображения Вы хотите разместить рядом названный tileImage
и a UIImageView
названный imageView
. То, что необходимо сделать, создают a UIImage
присваиваться к image
свойство imageView
. Можно сделать это как это:
CGSize imageViewSize = imageView.bounds.size;
UIGraphicsBeginImageContext(imageViewSize);
CGContextRef imageContext = UIGraphicsGetCurrentContext();
CGContextDrawTiledImage(imageContext, (CGRect){ CGPointZero, imageViewSize }, tileImage);
UIImage *finishedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageView.image = finishedImage;
Это создаст контекст растрового изображения желаемого размера, разместит изображение рядом в тот контекст, получит a UIImage
из контекста затем присвойте его UIImageView
. Можно действительно поместить этот код где угодно, пока представление изображения и изображение мозаики загружаются и готовы пойти.
Вместо того, чтобы пытаться изменить UIImageView, считайте разделение на подклассы UIView вместо этого. UIImageView специально предназначен для одного немозаичного изображения, и некоторые внутренности могут портить Вас. Это действительно не предназначается, чтобы быть измененным в способе, которым Вы описываете.
В подклассе UIView (UITiledImageView?) можно использовать drawRect: метод, чтобы сделать то, что Вы хотите. Можно даже создать ivars для изображения, его размера и свойств мозаичного размещения для большей гибкости и расширяемости.
Обновленный с демонстрационным проектом: http://github.com/kailoa/6tringle-tiledimageview/tree/master
Соответствующий код для прорисовки:
- (void)drawRect:(CGRect)rect
{
if (TiledImage) {
//Since we are retaining the image, we append with ret_ref. this reminds us to release at a later date.
CGImageRef image_to_tile_ret_ref = CGImageRetain(TiledImage.CGImage);
CGRect image_rect;
image_rect.size = TiledImage.size; //This sets the tile to the native size of the image. Change this value to adjust the size of an indivitual "tile."
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawTiledImage(context, image_rect, image_to_tile_ret_ref);
CGImageRelease(image_to_tile_ret_ref);
}
}
Я недавно сделал это путем создания пользовательского UIView.
@interface TiledImageView : UIView {
@private
UIImage *image_;
}
@property (nonatomic, retain) UIImage *image;
@end
и для.m файла:
@implementation TiledImageView
@synthesize image = image_;
- (void)dealloc {
[image_ release];
[super dealloc];
}
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
self.image = [UIImage imageNamed:@"BGTile.png"];
}
return self;
}
- (void)drawRect:(CGRect)rect {
// Drawing code
CGImageRef image = CGImageRetain(image_.CGImage);
CGRect imageRect;
imageRect.origin = CGPointMake(0.0, 0.0);
imageRect.size = CGSizeMake(CGImageGetWidth(image), CGImageGetHeight(image));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClipToRect(context, CGRectMake(0.0, 0.0, rect.size.width, rect.size.height));
CGContextDrawTiledImage(context, imageRect, image);
CGImageRelease(image);
}
@end
Если вы просто хотите разместить изображение в представлении, измените его на обычный UIView и разместите фон мозаикой с помощью UIColor initWithPatternImage:
backgroundView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageWithContentsOfFile:[self bundlePath:@"some_tile_image.png" inDirectory:@"tiles"]]];