添加图像在uibutton programmaticaly在iphone [英] adding images in uibutton programmaticaly in iphone
问题描述
新的iphone开发。我试图用图像开发按钮(当我点击按钮图像将显示)这个应用程序将开发像programmaticaly在iphone。
Im new to iphone development. i tried to develope button with image (when i click button the image will displayed) this application will developed like programmaticaly in iphone.
任何一个plz帮助我的问题
Can any one plz help me for my problem.
提前感谢。
推荐答案
/ p>
Do this:
UIImage *newButtonImage = [UIImage imageNamed:@"imageInMyProject.png"];
//Create image object from bundle. Name must include filetype; is case sensetive.
[myButton setImage:newButtonImage forState:UIControlStateNormal];
//Set the image for the button when it is in it's default state.
这种做事方式是伟大的,因为你可以设置图像显示根据需要不同。可以在此处找到不同的UIControlStates: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html#//apple_ref/c/tdef/UIControlState
This way of doing things is great, because you can set the image to show up differently as needed. The different UIControlStates can be found here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html#//apple_ref/c/tdef/UIControlState
快乐编码:)
这篇关于添加图像在uibutton programmaticaly在iphone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!