English 中文(简体)
UIButton 标题 不能发挥作用的形象
原标题:UIButton setTitleColor and setImage not working

我在利用故事波德故事片进行我的“i”项目。 在故事板上,我有一位感化控制员,使用原型电池进行表观测。 在原型电池中,我有一个UIButton(环形环形)被ook上UIButton子级。 该表从一个阵列中获取数据,数据在“ForRowAtIndexPath”中印刷。

Inside cellForRowAtIndexPath, I conditionally modify the cell s appearance. This is when I start getting problems. I am able to successfully change the text of the button. However, if I attempt to change the image of the button, using:

[cell.myButton setImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];

形象发生了变化,但案文消失。

如果我试图改变纽芬兰语的案文,使用:

[cell.myButton setTitleColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:.77] forState:UIControlStateNormal]

任何事情都不发生。 肤色保持不变(除非我也试图改变形象,在这种情况下,它完全消失)。

I am sensing I am doing something fundamentally wrong here -- do you have any suggestions?

最佳回答

用途

- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;   

改变形象,留下文字

用途

btn.titleLabel.textColor = yourcolor;

更改案文

问题回答

定义如下: 这在你的法典中可能是错误的。 该守则是:

myButton = [UIButton buttonWithType:UIButtonTypeCustom];

这是新开销的部分:

[myButton setBackgroundImage:yourimage forState:UIControlStateNormal];
    [myButton setTitleColor:yourcolor forState:UIControlStateNormal];

这是将不同特性划给“Button”的方法。 您也认为,这里有一套分类法,并确定了TitleColor。

    UIButtin  *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
   [myButton setFrame:CGRectMake(165, 205, 65, 40)];
   [myButton setTitleColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:.77]  forState:UIControlStateNormal];
   [myButton setTitle:@"Hi....." forState:UIControlStateNormal];
   [myButton addTarget:self action:@selector(btnClicked:)     forControlEvents:UIControlEventTouchUpInside];
   [myButton setBackgroundImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];
   [cell  addSubview:myButton];

感谢u。

我猜想你想要改变你的子邦背景:

[cell.myButton setBackgroundImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];

你的文字消失,因为你把纽顿前线的形象描绘成纽特的主要形象。

[cell.myButton setImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];

你们需要树立 but子的背景形象,以便你能够看到你的文本,因为图像将出现在UIButton的后方。

因此,将上述法典改为:

[cell.myButton setBackgroundImage:[UIImage imageNamed:@"mynewimage.png"] forState:UIControlStateNormal];




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签