如何为UIButton创建的自定义背景艺术实现scale-9(9切片) [英] How to implement scale-9 (9-slice) for custom background art created for UIButton

查看:97
本文介绍了如何为UIButton创建的自定义背景艺术实现scale-9(9切片)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了对可变大小的UIButton使用相同的背景图像,我需要以编程方式做什么? (通常称为9切片缩放或缩放-9)

What do I need to do programatically in order to use the same background image for UIButton of variable size? (commonly known as 9-slice scaling or scale-9)

推荐答案

退房:

- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight

在UIImage类中。

In the UIImage class.

如果我理解你正在寻找什么,这个允许你使用一个png定义按钮的外观,它可以垂直或水平拉伸到任何尺寸。

If I understand what you're looking for correctly, this while allow you to use one png to define how your button looks, and it will stretch to any size vertically or horizontally.

这篇关于如何为UIButton创建的自定义背景艺术实现scale-9(9切片)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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