添加图像在uibutton programmaticaly在iphone [英] adding images in uibutton programmaticaly in iphone

查看:77
本文介绍了添加图像在uibutton programmaticaly在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屋!

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