0

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

enter image description here

1
  • No, there is no way, you will have to use CGRectMake to give size to view. Commented Jul 11, 2014 at 7:25

2 Answers 2

3

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];
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.