我有一个UIButton(设置为“自定义”类型)。如果我在界面生成器中设置了图像,则图像将以透明的方式正确显示。但是,如果我试图在应用程序运行时以编程方式设置它(例如,更改按钮上显示的图像),透明度就不会正确显示——相反,我会得到图像的白色背景。
以下是我在代码中设置按钮图像的方式:
[die1Button setImage:[UIImage imageNamed:die1.dieImage] forState:UIControlStateNormal];
非常感谢任何想法。
我有一个UIButton(设置为“自定义”类型)。如果我在界面生成器中设置了图像,则图像将以透明的方式正确显示。但是,如果我试图在应用程序运行时以编程方式设置它(例如,更改按钮上显示的图像),透明度就不会正确显示——相反,我会得到图像的白色背景。
以下是我在代码中设置按钮图像的方式:
[die1Button setImage:[UIImage imageNamed:die1.dieImage] forState:UIControlStateNormal];
非常感谢任何想法。
Xcode记得以前版本的图像,那些没有透明度的图像——尽管我添加了带有透明度的新版本。我不得不做一个产品清洁,现在一切都如预期。
您正在使用的方法将图像放在按钮的前景上。我使用了以下方法,效果很好
[die1Button setBackgroundImage:[UIImage imageNamed:@"yourImageName.png"] forState:UIControlStateNormal];
希望这也适用于你…:)
Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...
I m using Xcode on OSX to develop command line C applications. I would also like to use Instruments to profile and find memory leaks. However, I couldn t find a way to display the console when ...
Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...
I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....
This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...
我跑了X条码,试图把我的手套放在我的电话上。 I m 获取错误信息:“正在设计的方案没有运行”。
Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...
In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...