- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的 iPhone 项目使用 StoryBoard 功能。在 Storyboard中,我有一个 View Controller ,其中包含使用原型(prototype)单元的 TableView 。在原型(prototype)单元内部,我有一个 UIButton(圆角矩形)连接到子类 UIButton 类。 tableview从数组中获取数据,并将数据打印在cellForRowAtIndexPath中。
在 cellForRowAtIndexPath 内,我有条件地修改单元格的外观。这是我开始遇到问题的时候。我能够成功更改按钮的文本。但是,如果我尝试更改按钮的图像,请使用:
[cell.myButton setImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];
图像发生变化,但文字消失。
如果我尝试更改按钮的文本颜色,请使用:
[cell.myButton setTitleColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:.77] forState:UIControlStateNormal]
什么也没发生。颜色保持不变(除非我也尝试更改图像,在这种情况下它会完全消失)。
我感觉我在这里做了一些根本错误的事情——你有什么建议吗?
最佳答案
使用
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;
更改图像并保留文本
使用
btn.titleLabel.textColor = yourcolor;
更改文本颜色
关于iphone - UIButton setTitleColor 和 setImage 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479977/
我正在尝试为所有UIBarButtonItem设置标题颜色 当我使用时: [[UIBarButtonItem appearance] setTitleColor:normalTitleColor f
为什么下面的代码可以工作... [signInBtn setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; [
我必须将 ffe1b1 的标题颜色设置为 ffe1b1 的 UIButton.RGB 值为 255,225,177。我正在尝试这段代码,但它没有正确反射(reflect)。我在网上搜索颜色分量是 0.
我正在为我的 iPhone 项目使用 StoryBoard 功能。在 Storyboard中,我有一个 View Controller ,其中包含使用原型(prototype)单元的 TableVie
从关于 SO 的问题中,我知道使用 setTitle ... forState 更改按钮标签文本是正确的: [_capturing_button setTitle:@"take photo!" for
我是一名优秀的程序员,十分优秀!