简体   繁体   中英

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.

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...

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM