shivangi
shivangi

Reputation: 187

create programmatically a UIView on mainWindow

I am creating a iphone app in which I am using Three20 open source for photo gallery. Now firstly I want to add a view in which some buttons are display and then tapping the button photo gallery show according to the button tapped category. When I firstly open my app should shows that button screen.

Upvotes: 0

Views: 379

Answers (2)

tacos_tacos_tacos
tacos_tacos_tacos

Reputation: 10585

UIView *buttonView = [[UIView alloc] initWithFrame:CGRectMake(40.0f,40.0f,240.0f,400.0f)]; 

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(10.0f,10.0f,80.0f,50.0f); //frame is RELATIVE to PARENT view
[button setTitle:@"Button Title" forState:UIControlStateNormal];

[buttonView addSubview:button];
[self.window addSubview:buttonView];

Upvotes: 1

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73638

You can create a new view like so -

UIView *v         = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
v.backgroundColor = [UIColor redColor];

Add v as a subview to your superview. hope this helps...

Upvotes: 1

Related Questions