1. 程式人生 > >Textfield首行縮排 游標顏色 清除按鈕樣式

Textfield首行縮排 游標顏色 清除按鈕樣式

首行縮排可以利用textfield的leftView做事

UILabel *usernameLeftView = [[UILabel alloc] initWithFrame:CGRectMake(0.f, 0.f, 10.f, 0.f)];
    usernameLeftView.backgroundColor = [UIColor clearColor];
    textField.leftView = usernameLeftView;

游標顏色:textField.tintColor = [UIColor blackColor];

清除樣式:textField.clearButtonMode = UITextFieldViewModeWhileEditing;(常用方法)

typedef NS_ENUM(NSInteger, UITextFieldViewMode) {
    UITextFieldViewModeNever,//從不
    UITextFieldViewModeWhileEditing,//編輯時
    UITextFieldViewModeUnlessEditing,//不在編輯狀態時
    UITextFieldViewModeAlways//總是
};

最終樣式:加了邊框的