Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Changing entire button background color
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="SoulRed12" data-source="post: 1051215" data-attributes="member: 146412"><p>I just have a quick question.</p><p></p><p>I'm writing a tic tac toe game for the heck of it (practice, I guess) and I want to make it so that when a player gets three in a row, it highlights the three buttons in some color. I can get the center rectangle of the buttons to change color but I can't get the entire button to change color like for example when you click on it. Here:</p><p></p><p><img src="http://img27.imageshack.us/img27/1912/7741.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>See? I'd like the buttons to nicely highlight the entire button but what they do now is just a rectangle in the middle and ignore the parts on the left and right. Note the buttons are just normal UIButtons (RoundRectButtons) created and placed in the view through code. Here's the code I used to do the highlighting:</p><p></p><p>[code]</p><p>- (void)highlightSpaces:(int)one second:(int)two third:(int)three {</p><p> if (one<9 && two<9 && three<9) {</p><p> //Note the 9 tic tac toe buttons are contained in one NSMutableArray</p><p> [[[buttonsArray objectAtIndex:one] titleLabel] setBackgroundColor:[UIColor greenColor]];</p><p> [[[buttonsArray objectAtIndex:two] titleLabel] setBackgroundColor:[UIColor greenColor]];</p><p> [[[buttonsArray objectAtIndex:three] titleLabel] setBackgroundColor:[UIColor greenColor]];</p><p> }</p><p>}[/code]</p><p></p><p>Any ideas would be appreciated. Thanks!</p></blockquote><p></p>
[QUOTE="SoulRed12, post: 1051215, member: 146412"] I just have a quick question. I'm writing a tic tac toe game for the heck of it (practice, I guess) and I want to make it so that when a player gets three in a row, it highlights the three buttons in some color. I can get the center rectangle of the buttons to change color but I can't get the entire button to change color like for example when you click on it. Here: [img]http://img27.imageshack.us/img27/1912/7741.png[/img] See? I'd like the buttons to nicely highlight the entire button but what they do now is just a rectangle in the middle and ignore the parts on the left and right. Note the buttons are just normal UIButtons (RoundRectButtons) created and placed in the view through code. Here's the code I used to do the highlighting: [code] - (void)highlightSpaces:(int)one second:(int)two third:(int)three { if (one<9 && two<9 && three<9) { //Note the 9 tic tac toe buttons are contained in one NSMutableArray [[[buttonsArray objectAtIndex:one] titleLabel] setBackgroundColor:[UIColor greenColor]]; [[[buttonsArray objectAtIndex:two] titleLabel] setBackgroundColor:[UIColor greenColor]]; [[[buttonsArray objectAtIndex:three] titleLabel] setBackgroundColor:[UIColor greenColor]]; } }[/code] Any ideas would be appreciated. Thanks! [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Changing entire button background color
Top