【问题标题】:'contentStretch' is deprecated: first deprecated in iOS 6.0?'contentStretch' 已弃用:首先在 iOS 6.0 中弃用?
【发布时间】:2013-10-14 07:11:05
【问题描述】:

当我输入时在我的代码中

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

它表明它已被弃用,有人可以帮我找到替代品吗?

【问题讨论】:

标签: ios objective-c xcode


【解决方案1】:
@property(nonatomic) CGRect contentStretch   NS_DEPRECATED_IOS(3_0,6_0); 

// 动画。默认为单位矩形 {{0,0} {1,1}}。现已弃用:请使用

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

 UIImage* cardImage = [[UIImage imageNamed:@"card_resizable.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(72, 0, 60, 0)];

【讨论】:

【解决方案2】:

假设 textViewBackgroundImage 是一个 UIImageView,

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

因此,现在我们应该使用“UIEdgeInsetsMake”来代替“CGRectMake”,而不是使用“contentStretch”属性,而应该使用“resizableImageWithCapInsets”方法。根据苹果的说法,效果是一样的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 2013-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多