Cursor visibility issue in ios7

前端 未结 4 1988
野的像风
野的像风 2021-02-12 19:04

Simply creating a UITextField in ios7 SDK but when I enter some input, text is shown UItextField but cursor isn\'t.

4条回答
  •  -上瘾入骨i
    2021-02-12 19:58

    As @Deepesh said, it's a matter of choosing the proper tint color. However it was not enough in my case since I am creating the UITextField programmatically and for some reason this setting is ignored.

    - (UITextField *)textfieldPhotoTitle
    {
        if (_textfieldPhotoTitle) {
            return _textfieldPhotoTitle;
        }
    
        _textfieldPhotoTitle = [[UITextField alloc] init];
        _textfieldPhotoTitle.placeholder = NSLocalizedString(@"PHOTO_UPLOAD_PHOTO_TITLE_PLACEHOLDER", @"");
        _textfieldPhotoTitle.keyboardType = UIKeyboardTypeASCIICapable;
        _textfieldPhotoTitle.layoutMinSize = CGSizeMake(0, 40);
        _textfieldPhotoTitle.layoutInsets = UIEdgeInsetsMake(11, 15, 9, 0);
        _textfieldPhotoTitle.tintColor = UIColor.blueColor; // IGNORED. NOT WORKING!!
        _textfieldPhotoTitle.delegate = self;
    
        return _textfieldPhotoTitle;
    }
    

    On the other hand, setting the color inside the textFieldDidBeginEditing did solve the issue:

    - (void)textFieldDidBeginEditing:(UITextField *)textField
    {
        textField.tintColor = UIColor.blueColor;
    }
    

    Working in iOS8.

提交回复
热议问题