2

I have a group of 31 buttons in a IBOutletCollection,

This is to create a calendar (i.e) the number of days in a month, I have to change the position of these buttons depending on the 1st days week day, that looks like a calendar.

I am not able to add target-action mechanism when I write code to implement the same in Xcode 4.2, so I tried do'g it in the Interface Builder using IBOutlet Collection.

But now the question is how do I change the postion of these bottons each one representing the one day of the month?

Till
  • 27,559
  • 13
  • 88
  • 122
user1136695
  • 31
  • 1
  • 2

3 Answers3

2

You can change the position like so:

myButton.frame = CGRectMake( x, y, width, height );

eg.

myButton.frame = CGRectMake( 20, 20, 100, 50 );
0

I'm not sure exactly what your calendar is for - but you might want to check out an open source iPhone calendar, it's pretty good: http://cocoacontrols.com/platforms/ios/controls/kal

You could either just use it as it is, or look at how it's implemented and use that to help you develop yours.

Jordan Smith
  • 10,310
  • 7
  • 68
  • 114
-1

For changing the position, use the center property of that button.

For example:

theButton.center = CGPointMake(10.0f, 10.0f);
Till
  • 27,559
  • 13
  • 88
  • 122