无标题文章

attributedPlaceholder

NSString *string = @"手机号";
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:string];
[placeholder setAttributes:@{
NSFontAttributeName:[UIFont systemFontOfSize:14],
NSForegroundColorAttributeName:[UIColor whiteColor]
} range:NSMakeRange(0, 2)];
self.loginPhoneNumber.attributedPlaceholder = placeholder;

继承TextField并重写
  • (void)drawPlaceholderInRect:(CGRect)rect
    {
    [self.placeholder drawInRect:CGRectMake(0, 10, rect.size.width, 25) withAttributes:@{
    NSFontAttributeName : self.font,
    NSForegroundColorAttributeName : [UIColor grayColor]
    }];
    }
不得姐.gif
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、设置UILabel行间距 NSMutableAttributedString*attrString=[[NSM...
    iOS祎阅读 2,202评论 0 0
  • iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等) 在iOS开发中...
    VickyLanLan阅读 206评论 0 1
  • //// AddressBookViewController.h// QRCodeScanApp//// Crea...
    奇怪的知识增加了阅读 318评论 0 0
  • 诸位看官,上次我们讲到,关河君整理了一下自来熟的代码,发现这家伙,好吧,我们还是来给他命个名吧,对,那家伙就叫阿晨...
    风雪关河阅读 231评论 0 1
  • 我没去过外面的世界 我不知道鸟儿思家的时候会干嘛 不知道鱼儿寂寞的时候会想什么 不知道树木是否也像我一样 为某个人...
    唐云杉阅读 242评论 0 0