ios - 启用安全类型的自定义 TextField

标签 ios uitextfield

我创建了自定义 TextField 来更改占位符颜色并将文本偏移量向上移动一点。

这里是代码。

-(void)drawPlaceholderInRect:(CGRect)rect{

    UIColor *color = [UIColor whiteColor];

    self.font = [UIFont fontWithName:@"Gotham-Medium" size:16];

    UIFont *font = self.font;

    NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
     font, NSFontAttributeName,
     [NSNumber numberWithFloat:1.0], NSBaselineOffsetAttributeName,color,NSForegroundColorAttributeName, nil];

    [[self placeholder] drawInRect:rect withAttributes:attrsDictionary];

}

- (CGRect)textRectForBounds:(CGRect)bounds {
    return CGRectInset( bounds , 1 , 5 );
}

// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
    return CGRectInset( bounds , 1 , 5 );
}

- (CGRect)placeholderRectForBounds:(CGRect)bounds{

    return CGRectInset( bounds , 1 , 5 );

}

由于自定义 texfield,当在密码字段中键入时,圆点显得很小,返回时 Action 变得正常。

打字时

enter image description here

输入后 enter image description here

最佳答案

enter image description here
enter image description here

From IOS 7 on words apple provided that functionality we can't do any thing and it's not an issue. its by default functionality for secured textfield.

关于ios - 启用安全类型的自定义 TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24320863/

相关文章:

iphone - 如何将背景图像放入 iPhone 中的文本字段和 TextView ?

ios - UITextField ResignFirstResponder 在 UIScrollView 上崩溃

iOS:调整所有 UILabel 字体的大小以匹配

iOS YTPlayerView 奇怪的行为

ios - 用于识别 iPhone 6 和 iPhone 6 plus 竖屏的尺寸等级

ios - ePub 文件的统一类型标识符是什么?

ios - 键入时将字符附加到文本字段

ios - swift2 核心数据和关系处理

iOS Swift - 多个 UITextField 移动 UIView

objective-c - UITableViewCell 中的 UITextfield 退出 FirstResnponder