How to display datepicker like that in iOS 7 calendar UIDatePicker

為{幸葍}努か 提交于 2019-12-04 05:29:47

You can try and use the OCCalendarController, Its so simple and comfortable. Just download the zipped file and get all the files named after the prefix OC.

Of which in OCCalendarViewController.m you can make the necessary changes by adding Okay or Cancel buttons programmatically, yourself.

To call the calendar view in your main file use the lines,

//Here's where the magic happens calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(150, 50) inView:self.view]; calVC.delegate = self; [self.view addSubview:calVC.view];

Also do include the following delegate to receive the date selection(if the user selects a date or date range)

- (void)completedWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate {

Finally you can also customize the arrow(which appears along with the calendar view) by using the code,

[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionRight]

Rest of the details can be found on the read me file. Try out yourself, It'll work like a charm.Cheers!

My open source project HSUDatePicker may help you. https://github.com/tuoxie007/HSUDatePicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!