0

I am pretty new in objective c so hopefully this all make sense.. I have declared UIView in .h file

@property (strong, nonatomic) UIView *menuViewone; 

In .m file i declared UIView in viewdidload

menuViewone =[[UIView alloc ]initWithFrame:CGRectMake(-400, 0, 200, 568) ];
[menuViewone setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:menuViewone];

and set the view frame in Button method

 - (IBAction)collectionmenutwo:(id)sender {
    if (menuViewone.frame.origin.x >=0 ) {
        [UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            menuViewone.frame=CGRectMake(-400, 100, 300, 568);
        } completion:^(BOOL finished) {

        }];
    }

    else
    {
        [UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            menuViewone.frame=CGRectMake(200, 100, 300, 568);
        } completion:^(BOOL finished) {

        }];
    }}

Now i want to declare the buttons in this UIView ...How i can do that programmatically?

user3482051
  • 45
  • 1
  • 7

1 Answers1

1

Just add buttons to the subview of that menuview of yours.

It would look something like this in the viewDidLoad of yours right after you declared your menuview.

UIButton *btn = [[UIButton] alloc] init];
btn.frame = CGRectMake(0,0,100,100);
//set other button properties here.
[menuViewone addSubview:btn];

For more specifics you can check this out: How do I create a basic UIButton programmatically?

Community
  • 1
  • 1
Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69