如何调整UIButton的imageSize? [英] How to adjust an UIButton's imageSize?

查看:3373
本文介绍了如何调整UIButton的imageSize?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何调整UIButton的图像大小?我正在设置这样的图像:

How can I adjust the image size of the UIButton? I am setting the image like this:

 [myLikesButton setImage:[UIImage imageNamed:@"icon-heart.png"] forState:UIControlStateNormal];

然而,这会将图像填满整个按钮,如何缩小图像?

However this fills up the image to the full button, how do I make the image smaller?

推荐答案

如果我理解你正在尝试做什么,你需要使用按钮图像边缘插图。类似于:

If I understand correctly what you're trying to do, you need to play with the buttons image edge inset. Something like:

myLikesButton.imageEdgeInsets = UIEdgeInsetsMake(top, left, bottom, right);

这篇关于如何调整UIButton的imageSize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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