Reputation: 20670
I am trying to create a view like the below one programmatically but it covers the whole screen and does not be like this. There could be some thing size = Freeform, but could not find code on google to handle this.
UIView *picker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 260)];
picker.backgroundColor = [UIColor whiteColor];
Actually I want to create this whole view programmatically not though interface Builder.
please help
Upvotes: 0
Views: 8543
Reputation: 4884
Create UIToolBar which has UIBarButtonItem(=Done). Set the UIToolBar as UIDatePicker's inputAccessoryView.
You don't even need a backgroundView to add Done button and date picker.
Upvotes: 0
Reputation: 31311
No other way than CGRectMake
if you want create the UIView
that covers the whole screen
UIView *picker = [[UIView alloc] initWithFrame:self.view.bounds];
picker.backgroundColor=[UIColor blueColor];
[self.view addSubview: picker];
if you want create the UIView
that not covers the whole screen
UIView *picker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 260)];
picker.backgroundColor=[UIColor blueColor];
[self.view addSubview: picker];
Upvotes: 3