如何在iphone中的Button中使用UIEdgeInsets属性 [英] How to use UIEdgeInsets property in Button in iphone

查看:97
本文介绍了如何在iphone中的Button中使用UIEdgeInsets属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS应用程序开发的新手,想知道如何在按钮中使用 UIEdgeInsets 属性,所以请指导我。

I am new to iOS application development and wanted to know how to use UIEdgeInsets property in button so please guide me.

推荐答案

首先,你的问题不是很明确,你想要实现什么,所以......提出一般性问题,得到一般答案。

First off, your question isn't very clear as to what you're attempting to achieve, so...ask a general question, get a general answer.

UIButton有三种类型为UIEdgeInsets的属性 - contentEdgeInsets titleEdgeInsets ,和 imageEdgeInsets 。您可以使用这些属性为所有按钮内容指定特定插入内容,包括标题和图像,或单独指定一个或另一个。

UIButton has three properties of type UIEdgeInsets – contentEdgeInsets, titleEdgeInsets, and imageEdgeInsets. You can use these properties to assign specific insets for all button content, including both the title and the image, or one or the other individually.

您可以使用以下方法创建UIEdgeInsets值 UIEdgeInsetsMake()功能。 UIEdgeInsets分别为顶部,左侧,底部和右侧(分别)的插入值封装了四个不同的CGFloat值。正插入值会缩小内容区域,而负插入值会有效地增加它。

You create UIEdgeInsets values using the UIEdgeInsetsMake() function. UIEdgeInsets encapsulates four different CGFloat values for the inset values of the top, left, bottom, and right (respectively) individually. Positive inset values shrink the content area, while negative inset values will effectively increase it.

如果您有关于如何在UIButton中使用UIEdgeInsets的更具体的问题,我建议您重新思考如何提出并再试一次。 :)

If you have a more specific question about how to use UIEdgeInsets with UIButton, I suggest you rethink how to ask it and try again. :)

编辑(解决评论中的问题):
听起来你想要做以下事情,然后:

Edit (to address question in comment): Sounds like you would want to do the following, then:

UIEdgeInsets titleInsets = UIEdgeInsetsMake(0.0, 7.0, 0.0, 0.0);
button.titleEdgeInsets = titleInsets;

这篇关于如何在iphone中的Button中使用UIEdgeInsets属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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