0

In my code when i type in

    textViewBackgroundImage.contentStretch = CGRectMake(0.5, 0.5, 0, 0);

it shows its been deprecated, Can someone help me in finding me the replacement for this?

Wodjefer
  • 345
  • 2
  • 6
  • 19
  • possible duplicate of [Replacement for UIView's contentStretch?](http://stackoverflow.com/questions/15663721/replacement-for-uiviews-contentstretch) – Toseef Khilji Oct 14 '13 at 07:15

2 Answers2

3
@property(nonatomic) CGRect contentStretch   NS_DEPRECATED_IOS(3_0,6_0); 

// animatable. default is unit rectangle {{0,0} {1,1}}. Now deprecated: please use

 -[UIImage resizableImageWithCapInsets:] to achieve the same effect.

 UIImage* cardImage = [[UIImage imageNamed:@"card_resizable.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(72, 0, 60, 0)];
Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
  • 2
    https://developer.apple.com/library/ios/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets: – Mina Oct 14 '13 at 07:16
  • If you were using contentStretch, you probably want to use -[UIImage resizableImageWithCapInsets: resizingMode:] and choose the 'stretch' mode. – Sam Jul 29 '14 at 17:10
1

Assuming textViewBackgroundImage is an UIImageView,

[textViewBackgroundImage.image resizableImageWithCapInsets:
                                        UIEdgeInsetsMake(0.5, 0.5, 0, 0)];

So, in place of 'CGRectMake', now we should use 'UIEdgeInsetsMake', and rather than using the 'contentStretch' property, we should use the 'resizableImageWithCapInsets' method. According to apple, the effect will be same.

Natasha
  • 6,651
  • 3
  • 36
  • 58