In your .h file #define MY_SCROLL_BUTTON_WIDTH 107 @interface ViewController : UIViewController { } @property (weak, nonatomic) IBOutlet UIScrollView *MyScrollView; In your .m file int x = 0; for (int KeyId = 0; KeyId < 10; KeyId++) { UIButton *MyButton = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, MY_SCROLL_BUTTON_WIDTH, 100)]; //x, y, width, height //[MyButton setTitle:HarmonicKeyDataAll[KeyId] forState:UIControlStateNormal]; […]