Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-06-2009, 01:49 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
Question UIButton setEnabled ???

I have a custom button, and i need to disable it sometimes.
But when i disable it it changes the color and opacity, and it looks ugly.
Is there anyway to disable the button without changing the opacity?

thanks
aryaxt is offline   Reply With Quote
Old 10-06-2009, 02:59 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 79
Default

Quote:
Originally Posted by aryaxt View Post
I have a custom button, and i need to disable it sometimes.
But when i disable it it changes the color and opacity, and it looks ugly.
Is there anyway to disable the button without changing the opacity?

thanks
Go to interface builder. Click on your button, and go to the inspector for it. Click on the dropdown and have disabled state highlighted. Then you can change what it will look like when disabled
__________________
iEncourage - Premier Encouragement App for iPhone/iPod Touch
iSleepWell- Premier Sleep Tracking App for iPhone/iPod Touch

iEasyProductions - "Simple, Yet Refined"
ieasyproductions is offline   Reply With Quote
Old 10-06-2009, 03:37 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
Default

thanks, but i am generating the button through code
Do you know how to code that?

Thanks in advance
aryaxt is offline   Reply With Quote
Old 10-06-2009, 04:43 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

Quote:
Originally Posted by aryaxt View Post
thanks, but i am generating the button through code
Do you know how to code that?

Thanks in advance
You can try to set the button's alpha value.
__________________

AppRelease
- Track your App Release Dates(Source Code provided).
LY MobileSoft on iTunes Store
stlau is offline   Reply With Quote
Old 10-07-2009, 05:41 AM   #5 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Lahore, Pakistan
Posts: 32
Send a message via MSN to stolidimran Send a message via Yahoo to stolidimran Send a message via Skype™ to stolidimran
Default

Quote:
Originally Posted by aryaxt View Post
thanks, but i am generating the button through code
Do you know how to code that?

Thanks in advance
Try this code...

Code:
[yourButton setBackgroundImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateDisabled];
(Tip: Use the same image.png you used for normal state)

Hope it helps!
__________________
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” Anonymous

Follow me on Twitter
http://twitter.com/stolidimran

Last edited by stolidimran; 10-07-2009 at 05:45 AM.
stolidimran is offline   Reply With Quote
Old 10-07-2009, 09:53 AM   #6 (permalink)
ftm
FasterThanMonkeys.com
 
Join Date: Mar 2009
Location: Southern California
Posts: 523
Send a message via AIM to ftm
Default

Just a tip... Apple recently rejected our Jam Packed! game for using disabled buttons in certain parts of the User Interface. They said disabled buttons confuse the users. We had to change the game to hide buttons that are not available at certain points instead of disabling them, and then we were able to get approval.

That made the code easier (didn't need a "disabled state", just set the .hidden attribute), but it did mean a slight layout change for us. Hiding buttons was leaving the interface unbalanced, so we actually changed the whole screen.

Just thought I'd pass that on...
__________________


Website: http://fasterthanmonkeys.com

iScore Baseball Scorekeeper Top baseball scorekeeping app for iPhone
Bug Squash Reached #1 kids game in 15+ countries including USA, now with OpenFeint
Jam Packed! Fun puzzle game for all ages
Jam Packed Christmas Holiday puzzle game!
iScore Basketball Scorekeeper Best basketball scorekeeping application
ftm is offline   Reply With Quote
Reply

Bookmarks

Tags
color, opacity, setenabled, uibutton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 246
18 members and 228 guests
ADY, Alsahir, beleg_1998, Dani77, diyora, iDifferent, iph_s, JamesCahall, JasonR, mer10, Monstertaco, prchn4christ, Robiwan, Rudy, smithdale87, Speed, spiderguy84, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:15 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0