3

I have a small tile image url (50x50) that I want to set for SDAnimatedImageView that occupies full screen. Is it possible to make my source tile image repeat within SDAnimatedImageView in vertical and horizontal axis so it occupies all space? Thus far closest I got to is using contentMode on SDAnimatedImageView to stretch this tile image, but that looks completely off.

Thus far I am not doing anything crazy, just [self sd_setImageWithURL:url]; where self is SDAnimatedImageView

Ilja
  • 44,142
  • 92
  • 275
  • 498
  • Possibility duplicate of https://stackoverflow.com/questions/30001569/repeat-image-horizontally-and-vertically – Duy Nguyen Aug 30 '19 at 15:06

1 Answers1

2

I haven't tried this myself but I think you would have to use the image downloader and then set the image on the ImageView yourself with the tile option set.

- (nullable SDWebImageDownloadToken *)
    downloadImageWithURL:(nullable NSURL *)url
               completed:
                   (nullable SDWebImageDownloaderCompletedBlock)completedBlock;

Docs

- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets 
                            resizingMode:(UIImageResizingMode)resizingMode;

Docs

So I think it would work something like this:

[[SDWebImageManager sharedManager] downloadImageWithURL:imageURL
                                                options:SDWebImageRetryFailed
                                              completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
    self.imageView.image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];

}];
Nordeast
  • 1,353
  • 13
  • 21