jamshed jamshed - 1 year ago 140
Objective-C Question

iOS 9.2 UIDatePicker corner and border not working

I am working with UIDatePicker where i need to set borderWidth, borderColor and cornerRadius. But i can't make it work. I have masksToBounds to YES also.

dateBtn.layer.borderWidth = 2.0;
dateBtn.layer.borderColor = [[UIColor redColor]CGColor];
dateBtn.layer.cornerRadius =5.0;

Any solution please ?

Answer Source

Works great for me:

self.datePicker.layer.borderColor   = [UIColor grayColor].CGColor;
self.datePicker.layer.borderWidth   = 1.0f;
self.datePicker.layer.cornerRadius  = 5.0f;
self.datePicker.layer.masksToBounds = YES;

Try my code in given order of it lines. Date picker with color rounded border

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download