Discussion Forums  >  Suggestions, Ideas, Wish List

Replies: 6    Views: 93

shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
08/03/13 11:36 AM (12 years ago)

Centering buttons on Menu Simple

Hi, I have a menu with two buttons on it. The issue with this is that, with the "grid" formatting, the two buttons are centered, but are also close to the top of the screen. Is there a way to put them more towards the middle? Thanks, David
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
08/03/13 10:08 PM (12 years ago)
So, if you inspect the code on the BT_screen_menuButton.m file, you should notice the settings starting around line 400. If you're using the 'grid' menu option, you'll have to manually edit the code. Currently it's set to: **************************** //grid if([buttonLayoutStyle isEqualToString:@"grid"] || [buttonLayoutStyle isEqualToString:@""]){ contentWidth = deviceWidth; contentHeight = ((boxHeight + labelHeight) * (numButtons + 10)) / buttonsPerRow - (deviceHeight * 1.5); if(contentHeight < deviceHeight) contentHeight = (deviceHeight + 50); self.myScrollView.frame = CGRectMake(0, 0, deviceWidth, deviceHeight); self.myScrollView.contentSize = CGSizeMake(contentWidth, contentHeight); } **************************** Could change the self.myScrollView.frame line to something like: CGRectMake(0, (deviceHeight-contentHeight)/2, deviceWidth, contentHeight); **or** CGRectMake(0, deviceHeight/3, deviceWidth, deviceHeight); **depends on how many buttons and look you're going for** **************************** Alternatively, you could try to set the 'margin' property to get the desired effect.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
08/04/13 08:05 AM (12 years ago)
Hi Chris, Using CGRectMake(0, deviceHeight/3, deviceWidth, deviceHeight); worked! What ended up happening was, I have a screen with two buttons and one with four buttons. When I fixed the two button one it completely messed up the four-button one, so I put the four button one in the grid layout and the two button one in the horizontal top layout so they could have separate settings. Then I centered the four button one and two button one with your CGRectMake(0, deviceHeight/3, deviceWidth, deviceHeight); suggestion (I played around a little and found numbers that centered it more), and then got both of them perfectly centered! Thanks a lot Chris! David
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
08/06/13 09:16 PM (12 years ago)
No problem - glad you got it worked out!
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
08/14/13 08:02 AM (12 years ago)
Hi Chris, I just realized that while I centered the buttons, I only did it for the iPhone 4/4S size. Do you know if there is a way I can center it for both the iPhone 4/4S size and the iPhone 5 size? Thanks, David
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
08/15/13 04:36 PM (12 years ago)
Hi Chris, I actually got it! I just added if(deviceHeight<500){ for iPhone 4/4s and then copy and pasted the same myscrollview stuff. Then for iPad, I did the same except it was if(deviceHeight>900). Thanks, David
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
08/17/13 07:35 AM (12 years ago)
Great - I knew you'd get it if you played around with it long enough! :)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.