How to display UIDatePicker if user hit the UITextfield Programmatically

后端 未结 7 1338
刺人心
刺人心 2021-02-05 14:31

I\'d like to Display UIDatePicker only when user the UITextField is Clicked. When the date is picked, it should be shown in the same UITextField.I want to implement UIDatePicker

7条回答
  •  广开言路
    2021-02-05 15:12

        UIDatePicker *picker1   = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 210, 320, 216)];
        [picker1 setDatePickerMode:UIDatePickerModeDate];
        picker1.backgroundColor = [UIColor whiteColor];
        [picker1 addTarget:self action:@selector(startDateSelected:) forControlEvents:UIControlEventValueChanged];
    
    //    [picker1 addSubview:toolBar];
        self.birthTxt.inputView  = picker1; // Here birthTxt is Textfield Name replace with your name
    

提交回复
热议问题