替换UIView的内容实力? [英] Replacement for UIView's contentStretch?

查看:97
本文介绍了替换UIView的内容实力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 6.0中,不推荐使用UIView的contentStretch属性。
如何使用new / old / other API实现相同的功能?

In iOS 6.0 the contentStretch property of UIView was deprecated. How can I achieve the same functionality with new/old/other API?

我正在寻找的功能只是延伸图像的一部分(除了上一个UIButton的边缘)。

The functionality I am looking for is stretching just part of an image (everything but the edges) on a UIButton.

推荐答案

使用resizableImageWithCapInsets和UIEdgeInsets使拉伸的UIButton背景图像。例如:

Use resizableImageWithCapInsets and UIEdgeInsets to make a stretching UIButton background image. For example:

UIImage* image = [UIImage imageNamed:@"image.png"];
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 20)];
[button setBackgroundImage:image forState:UIControlStateHighlighted];

我认为你不能在水平和垂直方向上拉伸多个像素。

I don't think you can stretch more than one pixel both horizontal and vertical.

希望这有帮助。

这篇关于替换UIView的内容实力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆