Sunday, June 2, 2013

UITextField UITextBorderStyleNone example in Objective C (iOS).


UITextField UITextBorderStyleNone

UITextFieldBorderStyle
The type of border drawn around the text field.

typedef enum {
UITextBorderStyleNone,
UITextBorderStyleLine,
UITextBorderStyleBezel,
UITextBorderStyleRoundedRect
} UITextBorderStyle;

Constants
UITextBorderStyleNone
The text field does not display a border.
UITextBorderStyleLine
Displays a thin rectangle around the text field.
UITextBorderStyleBezel
Displays a bezel-style border for the text field. This style is typically used for standard data-entry fields.
UITextBorderStyleRoundedRect
Displays a rounded-style border for the text field.

UITextField UITextBorderStyleNone example.
UITextField *tfText = [[UITextField alloc] initWithFrame:CGRectMake(65, 200, 200, 30)];
    tfText.backgroundColor = [UIColor colorWithRed:0.2 green:0.9 blue:0.5 alpha:0.3];      
    tfText.textAlignment = UITextAlignmentCenter;
    // Border Style None
    [tfText setBorderStyle:UITextBorderStyleNone];
    [self.view addSubview:tfText];
    [tfText release];

Example of [UITextField UITextBorderStyleNone].
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.bounds.size.width, 44.0f)];
[myTextField setBorderStyle:UITextBorderStyleNone];
[myTextField setPlaceholder:@"Title (optional)"];
[self.view addSubview:myTextField];

UIView *blackLineView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, myTextField.frame.origin.y + myTextField.frame.size.height, self.view.bounds.size.width, 3.0f)];
[blackLineView setBackgroundColor:[UIColor colorWithWhite:0.0f alpha:0.4f]];
[self.view addSubview:blackLineView];

UITextView *myTextView = [[UITextView alloc] initWithFrame:CGRectMake(0.0f, blackLineView.frame.origin.y + blackLineView.frame.size.height, self.view.bounds.size.width, 200.0f)];
[self.view addSubview:myTextView];

UITextField UITextBorderStyleNone example.
textField.borderStyle = UITextBorderStyleLine;
textField.borderStyle = UITextBorderStyleNone;

End of UITextField UITextBorderStyleNone example article.