以编程方式设置UIButton的buttonType [英] set UIButton's buttonType programmatically

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

问题描述

我在IB中添加了 UIButton ,但是此按钮后面的视图会改变颜色,我需要在 InfoDark <之间切换按钮的类型/ em>和 InfoLight 。但奇怪的是, buttonType 属性是只读的。那么如何在明暗信息按钮之间切换?

I have a UIButton which I've added in IB, however the view behind this button changes color and I need to switch the button's type between InfoDark and InfoLight. Bizarrely though, buttonType property is read only. So how can i switch between light and dark info buttons?

推荐答案

无法更改。 buttonType 一旦设置完毕。

There's no way to change the .buttonType once it's set.

您可以准备两个按钮,并根据背景颜色隐藏其中一个按钮。

You can prepare two buttons, and hide one of them depending on the background color.

这篇关于以编程方式设置UIButton的buttonType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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