开发者

create programmatically a UIView on mainWindow

开发者 https://www.devze.com 2023-03-27 02:25 出处:网络
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

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 开发者_StackOverflow社区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];
0

精彩评论

暂无评论...
验证码 换一张
取 消