UIButton 状态 [英] UIButton states

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

问题描述

我正在制作多个看起来像这样的自定义按钮:

I am making multiple custom buttons that look much like this:

这是一个简单的按钮,在指示器视图"中带有绿色或灰色.我需要解释的是:在 interfacebuilder 中,按钮可以具有四种状态;正常、突出显示、选中和禁用.当我为除禁用之外的所有内容提供图像时,我认为正常情况是没有触摸按钮时,突出显示的是当您将手指放在按钮上时,选择是在您松开手指后.

It is a simple button with either the green or gray in the "indicator view". What I need some explanation for is: In interfacebuilder there are four states a button can have; Normal, Highlighted, Selected and Disabled. When I provide images for everything except disabled I thought that normal would be when no touches were made on the button, highlighted is while you hold your finger on it and selected would be when after you release finger.

但是我不认为那是现在.我使用 touch-up-inside 事件.我需要在按钮上设置 selected/highlighted 等属性是否正确?

However I do not think thats right now. I use the touch-up-inside event. Is it correct that I need to set the selected/highlighted etc property on the button?

感谢您抽出宝贵时间.

推荐答案

您可能希望设置为选中而不突出显示.突出显示在触摸 UIButton 时使按钮变暗一小部分.UIButton 可以自动修改你的图片,所以通常你不需要提供高亮图片.
禁用是当它被禁用时.
Selected 是它被选中的时候.您可以在内部事件的触摸上反转选择标志以制作状态按钮.
[button setSelected:![button isSelected]];

You might want to set to selected and not highlighted. Highlight is darkening the button for a fraction when touching the UIButton. UIButton can modify your image automaticaly so usually you don't need to provide a highlight image.
Disabled is when it is disabled.
Selected is when it is selected. You can invert the select flag on touch up inside event to make a state button.
[button setSelected:![button isSelected]];

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

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