内容拉伸属性在 iOS 6.0 中已被弃用,我找不到似乎可以正常工作的替代方法。
这是在 iOS 6.0 中有效但已弃用的代码:
UIImageView *sectionsSeparator = [[UIImageView alloc] initWithFrame:CGRectMake(x, 0, separatorWidth, totalHeight)];
sectionsSeparator.image = [self imageForSectionsSeparator];
sectionsSeparator.contentStretch = CGRectMake(0, 0.25f, 1, 0.5f);
[self addSubview:sectionsSeparator];
我尝试了下面的代码,但图像没有正确排列:
UIImageView* sectionsSeparator = [[UIImageView alloc] initWithFrame:CGRectMake(x, 0, separatorWidth, totalHeight)];
[sectionsSeparator setImage:[[self imageForSectionsSeparator] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 0.25f, 1.0f, 0.5f)]];
[overlayView addSubview:sectionsSeparator];
也许我错过了一些东西,有什么建议吗?