MAFUITextField uses the MAFStyling protocol to extend the native UITextField class with MAF styling capability. MAFUITextField can also use different indicators to mark mandatory fields and fields with invalid values.
MAFUITextField *textFieldRounded = [[MAFUITextField alloc] initWithFrame:CGRectMake(10, 40, 300, 30)] ; textFieldRounded.borderStyle = UITextBorderStyleRoundedRect; textFieldRounded.placeholder = @"<enter text>"; //place holder //explicit call is needed to apply default style. [textFieldRounded applyMAFStyleWithMandatoryIcon:YES WithErrorIcon:YES UseControlNames:YES];This code presents this MAFUITextField:
[textFieldRounded addTarget:self action:@selector(errorCheck:) forControlEvents:UIControlEventEditingChanged];The call is triggered to check the validity of the current value after each additional character is typed in the text field.
//Create The Textfields textFieldRounded = [[MAFUITextField alloc] initWithFrame:CGRectMake(10, 40, 300, 30)] ; textFieldRounded.mafStyleName = @"TextBoxSample"; textFieldRounded.font = [UIFont systemFontOfSize:17.0]; //font size textFieldRounded.placeholder = @"<enter text>"; //place holder textFieldRounded.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support textFieldRounded.keyboardType = UIKeyboardTypeDefault; // type of the keyboard textFieldRounded.returnKeyType = UIReturnKeyDone; // type of the return key //set to apply style with mandatory icon and error icon. [textFieldRounded applyMAFStyleWithMandatoryIcon:YES WithErrorIcon:YES UseControlNames:YES];To apply SAP style to MAFUITextField, define these properties in Styles.xml:
<Style TargetType="TextBox" platform="ios"> <Setter Property="Background" Value="#FEFEFE"/> <Setter Property="FontFamily" Value="Helvetica"/> <Setter Property="FontSize" Value="15"/> <Setter Property="HorizontalContentAlignment" Value="Left"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Foreground" Value="#000000"/> <Border BorderBrush="#ABABAB" BorderThickness="1" CornerRadius="8"/> </Style>
Background | Color of the UITextField background; can be only a solid color, no freestyle gradient. Colors are defined as RGBA (red, green, blue, alpha). |
FontFamily | The control's font family. |
FontSize | The control's font size. |
HorizontalContentAlignment | Horizontal alignment of the control's text. |
Foreground | The color of the control’s text. |
Border | The border attributes of the MAFUITextField include:
|