SVGKImageView.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #import "SVGKImageView.h"
  2. @implementation SVGKImageView
  3. @synthesize image = _image;
  4. @synthesize showBorder = _showBorder;
  5. - (id)init
  6. {
  7. if( [self class] == [SVGKImageView class ])
  8. {
  9. NSAssert(false, @"You cannot init this class directly. Instead, use a subclass e.g. SVGKFastImageView");
  10. return nil;
  11. }
  12. else
  13. return [super init];
  14. }
  15. -(id)initWithFrame:(CGRect)frame
  16. {
  17. if( [self class] == [SVGKImageView class ])
  18. {
  19. NSAssert(false, @"You cannot init this class directly. Instead, use a subclass e.g. SVGKFastImageView");
  20. return nil;
  21. }
  22. else
  23. return [super initWithFrame:frame];
  24. }
  25. - (id)initWithCoder:(NSCoder *)aDecoder
  26. {
  27. if( [self class] == [SVGKImageView class ])
  28. {
  29. NSAssert(false, @"Xcode is trying to load this class from a StoryBoard or from a NIB/XIB files. You cannot init this class directly - in your Storyboard/NIB file, set the Class type to one of the subclasses, e.g. SVGKFastImageView");
  30. return nil;
  31. }
  32. else
  33. return [super initWithCoder:aDecoder];
  34. }
  35. - (id)initWithSVGKImage:(SVGKImage*) im
  36. {
  37. NSAssert(false, @"Your subclass implementation is broken, it should be calling [super init] not [super initWithSVGKImage:]. Instead, use a subclass e.g. SVGKFastImageView");
  38. return nil;
  39. }
  40. /**
  41. The intrinsic sized of the image view.
  42. This is useful for playing nicely with autolayout.
  43. @return The size of the image if it has one, or CGSizeZero if not
  44. */
  45. - (CGSize)intrinsicContentSize {
  46. if ([self.image hasSize]) {
  47. return self.image.size;
  48. }
  49. return CGSizeZero;
  50. }
  51. #if SVGKIT_MAC
  52. - (BOOL)isFlipped {
  53. return YES;
  54. }
  55. #endif
  56. @end