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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 01-17-2011, 06:32 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 9
roko is on a distinguished road
Default problem with UIButton background color

hi guys!

Here is screenshot where is my buttons(UIButton with custom image). Behind the buttons you can see white background colour:


How to take that white background away?

I was trying to sort it out working with next UIButton' methods:setTitleColor, setTitleShadowColor and setBackgroundColor, but it doesn't work.

Has anyone any idea how to remove that white background?
roko is offline   Reply With Quote
Old 01-17-2011, 06:43 AM   #2 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

Quote:
Originally Posted by roko View Post
hi guys!

Here is screenshot where is my buttons(UIButton with custom image). Behind the buttons you can see white background colour:


How to take that white background away?

I was trying to sort it out working with next UIButton' methods:setTitleColor, setTitleShadowColor and setBackgroundColor, but it doesn't work.

Has anyone any idea how to remove that white background?
Here is a tutorial how to set background color programmatically, it shows you how to set it to clear.

Changing UITextField Background Color Programmatically
MozyMac is offline   Reply With Quote
Old 01-17-2011, 07:03 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 9
roko is on a distinguished road
Default

Quote:
Originally Posted by MozyMac View Post
Here is a tutorial how to set background color programmatically, it shows you how to set it to clear.

Changing UITextField Background Color Programmatically
thanks but it doesn't help. Here is what i can see:


maybe it would be helpful to you and other to show how i create my UIButton. So here is code:
Code:
//jumpButton
UIButton *jumpButton;
		self.jumpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
		jumpButton.frame = CGRectMake(0, 0, 55, 55);
		affTransf.tx = 10;
		affTransf.ty = 380;
		[jumpButton setTransform:affTransf];
		[jumpButton addTarget:self action:@selector(jumpButtonActionDown) forControlEvents:UIControlEventTouchDown |
		UIControlEventTouchDragEnter];
		[jumpButton addTarget:self action:@selector(jumpButtonActionUp) forControlEvents:UIControlEventTouchUpInside |
		UIControlEventTouchDragExit];
		jumpButton.backgroundColor = [UIColor blackColor];
		
		UIImage *jumpButtonImg = [UIImage imageNamed:@"jump_test.png"];
		[jumpButton setImage:jumpButtonImg forState:UIControlStateNormal];
		
		UIImage *jumpButtonImgH = [UIImage imageNamed:@"jump_n_a_test.png"];
		[jumpButton setImage:jumpButtonImgH forState:UIControlStateHighlighted];
		
		[[[[CCDirector sharedDirector] openGLView] window] addSubview:jumpButton];

Last edited by roko; 01-17-2011 at 07:11 AM.
roko is offline   Reply With Quote
Old 01-17-2011, 09:01 AM   #4 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

Code:
		self.jumpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

try changing that to :

Code:
 self.jumpButton = [UIButton buttonWithType:UIButtonTypeCustom];
MozyMac is offline   Reply With Quote
Old 01-17-2011, 09:49 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 9
roko is on a distinguished road
Default

Quote:
Originally Posted by MozyMac View Post
Code:
		self.jumpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

try changing that to :

Code:
 self.jumpButton = [UIButton buttonWithType:UIButtonTypeCustom];
thank you very much!

Code:
self.jumpButton = [UIButton buttonWithType:UIButtonTypeCustom]
and

Code:
biteButton.backgroundColor = [UIColor clearColor];
really helped


but i have heard that using UIButton in the Cocos2d can inhibit my program on the old device.

so i have found out this code:
Code:
biteBt = [CCMenuItemImage itemFromNormalImage:@"bite_test.png" selectedImage:@"bite_n_a_test.png" target:self selector:@selector(biteButtonActionDown)];
		biteBt.position = ccp(200,120);
		
		CCMenu * menu = [CCMenu menuWithItems:biteBt,nil];
									
		[self addChild:menu z:1000];
thank you

Last edited by roko; 01-18-2011 at 09:40 AM.
roko is offline   Reply With Quote
Old 01-17-2011, 11:29 PM   #6 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

You're most welcome
MozyMac is offline   Reply With Quote
Reply

Bookmarks

Tags
background, colour, 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: 366
10 members and 356 guests
7twenty7, blueorb, dre, iAppDeveloper, iGamesDev, Mah6447, Morrisone, mottdog, sacha1996, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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