DetailViewController.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "DetailViewController.h"
  9. #import <SDWebImage/SDWebImage.h>
  10. @interface DetailViewController ()
  11. @property (strong, nonatomic) IBOutlet SDAnimatedImageView *imageView;
  12. @end
  13. @implementation DetailViewController
  14. - (void)configureView {
  15. if (!self.imageView.sd_imageIndicator) {
  16. self.imageView.sd_imageIndicator = SDWebImageProgressIndicator.defaultIndicator;
  17. }
  18. [self.imageView sd_setImageWithURL:self.imageURL
  19. placeholderImage:nil
  20. options:SDWebImageProgressiveLoad];
  21. self.imageView.shouldCustomLoopCount = YES;
  22. self.imageView.animationRepeatCount = 0;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self configureView];
  27. self.navigationItem.rightBarButtonItem = [UIBarButtonItem.alloc initWithTitle:@"Toggle Animation"
  28. style:UIBarButtonItemStylePlain
  29. target:self
  30. action:@selector(toggleAnimation:)];
  31. }
  32. - (void)toggleAnimation:(UIResponder *)sender {
  33. self.imageView.isAnimating ? [self.imageView stopAnimating] : [self.imageView startAnimating];
  34. }
  35. @end