iOS iOS - 2 years ago 139
Objective-C Question

UITextField - Rounded corner issue

I bring the issue forward which I face. I am creating a

programmatically as below.

UItextField *mobileNumberField = [[UITextField alloc] initWithFrame:CGRectMake(10, 195, 300, 41)];
mobileNumberField.delegate = self;
mobileNumberField.borderStyle = UITextBorderStyleRoundedRect;
[mobileNumberField.layer setCornerRadius:14.0f];
mobileNumberField.placeholder = @"Mobile Number";
[self.paymentsHomeView addSubview:mobileNumberField];

The output is the attached image.

enter image description here

I dont know why is it breaking at the corners. Help me to fix my text field like the image attached below.

enter image description here

Thanks in advance..!

Answer Source

just remove this line...

mobileNumberField.borderStyle = UITextBorderStyleRoundedRect;

and add this code also..

    [mobileNumberField setBackgroundColor:[UIColor whiteColor]];
    [mobileNumberField.layer setBorderColor:[UIColor grayColor].CGColor];
    [mobileNumberField.layer setBorderWidth:1.0];

i hope this help you..

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