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

查看:20
本文介绍了如何调整 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 = UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)

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

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